ld of binutils 2.12 appends two (garbage?) bytes
Felix Kühling
fxkuehl@gmx.de
Sat May 11 09:49:00 GMT 2002
On Sat, 11 May 2002 20:36:18 +0930
Alan Modra <amodra@bigpond.net.au> wrote:
> On Fri, May 10, 2002 at 04:56:10PM +0200, Felix Kühling wrote:
> > I'm assembling and linking a master boot record for the ia32
> > architecture which has to be exactly 446 bytes long. After upgrading
> > from binutils 2.10 to 2.12 it gets 2 bytes too long. I first assumed the
> > linker tried to make the length divisible by 4.
>
> That's exactly what it does.
>
> > But it does not append
> > zeros. Here is the end of the hexdump:
>
> No, it appends NOPs in the .text section, and x86 gas chooses
> "mov %esi,%esi" as a two byte NOP. I'm not sure what to do about
So gas is the bad guy :). As 'size' reported a text section length of
446 bytes I thought it was ld.
> fixing your particular problem. Perhaps we should remove the
> record_alignment calls in tc-i386.c:md_begin. They've been there for
> a very long time, as it's a good idea to align entry points into code,
> but not vital on x86. Richard Henderson made some changes (see
> http://sources.redhat.com/ml/binutils/2000-12/msg00305.html) to pad
> out the end of sections to their alignment values, and this change in
> combination with the 4 byte alignment of .text causes your problem.
>
> I'm tempted to remove
>
> /* The last subsegment gets an aligment corresponding to the
> alignment of the section. This allows proper nop-filling
> at the end of code-bearing sections. */
> if (!frchainP->frch_next || frchainP->frch_next->frch_seg != now_seg)
> alignment = get_recorded_alignment (now_seg);
>
> >from write.c:subsegs_finish. Hmm, for those targets with minimum insn
> lengths, "#define SUB_SEGMENT_ALIGN MIN_INSN_ALIGN" and defining
> MIN_INSN_ALLIGN might be a good idea. Richard?
Ok, I commented out the above lines and it works for me. Thanks for your
help.
>
> --
> Alan Modra
> IBM OzLabs - Linux Technology Centre
>
Regards,
Felix
__\|/__ ___ ___ ___
__TschüÃ_______\_6 6_/___/__ \___/__ \___/___\___You can do anything,___
_____Felix_______\Ã/\ \_____\ \_____\ \______U___just not everything____
fxkuehl@gmx.de >o<__/ \___/ \___/ at the same time!
More information about the Binutils
mailing list