This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld of binutils 2.12 appends two (garbage?) bytes
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Felix Kühling <fxkuehl at gmx dot de>
- Cc: binutils at sources dot redhat dot com, Richard Henderson <rth at redhat dot com>
- Date: Sat, 11 May 2002 20:36:18 +0930
- Subject: Re: ld of binutils 2.12 appends two (garbage?) bytes
- References: <20020510165610.1e2046e1.felix@viking.ostkupan.studenthem.gu.se>
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
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?
--
Alan Modra
IBM OzLabs - Linux Technology Centre