This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] initial i386-nacl target support for gas
On Fri, Jan 20, 2012 at 3:37 PM, H.J. Lu <email@example.com> wrote:
> Can you change linker to pad text section with nops?
I imagine it's possible, but it's certainly going to be a lot more hairy.
The way it's partially done today is with =0x90909090 in the linker script.
But that only covers the sections named in the linker script, not any
orphan sections that might be placed.
To do it in a general way in the linker would look at SHF_EXECINSTR
(i.e. SEC_CODE) on an input section to decide. Then it would need some
backend stuff to tell it what fill to use. I can imagine that some
machines might actually need something different than repeating a single
sequence (for x86, repeating a single byte is enough regardless of the size
and alignment of fill required).
The assembler already has handy machinery for all of that, since it does it
optimally for .align directives followed by more instructions rather than
the end of the section. And the only cost is increasing .o size by a
negligible number of bytes. So I don't really see how it would be any
practical improvement to do it in the linker, while it would clearly be a
great deal more work and more likely to introduce new bugs trying to do it.