When an output section requires alignment padding between input sections, and the input sections are executable (SHF_EXECINSTR/SEC_CODE), the linker should use nop instructions to pad rather than zeros. For known named sections mentioned in the linker script, this is accomplished using the =FILL syntax in the script. But that doesn't input cover sections not mentioned at all in the linker script. Here is an example: $ cat foo.s .section code1,"ax",@progbits .align 32 ret $ ./gas/as-new -o foo.o foo.s $ ./ld/ld-new -o foo foo.o foo.o ./ld/ld-new: warning: cannot find entry symbol _start; defaulting to 0000000000400078 $ objdump -rd foo foo: file format elf64-x86-64 Disassembly of section code1: 0000000000400080 <code1>: 400080: c3 retq ... 40009d: 00 00 add %al,(%rax) 40009f: 00 c3 add %al,%bl $ There is a similar problem with two differently-named sections that become contiguous in the output file. But that case is not readily displayed by objdump, which omits the intersection bytes altogether. Note that gold almost gets this right. It uses nops for the padding. But in this particular case, instead of a long string of nop instructions, it generates a jump around the gap, but leaves the rest of the gap filled with zeros rather than valid instructions.
Created attachment 6173 [details] A patch Here is a proposed patch.
Created attachment 6175 [details] An improved patch
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2012-01-31 17:54:39 Modified files: bfd : ChangeLog archures.c bfd-in2.h configure configure.in cpu-alpha.c cpu-arc.c cpu-arm.c cpu-avr.c cpu-bfin.c cpu-cr16.c cpu-cr16c.c cpu-cris.c cpu-crx.c cpu-d10v.c cpu-d30v.c cpu-dlx.c cpu-epiphany.c cpu-fr30.c cpu-frv.c cpu-h8300.c cpu-h8500.c cpu-hppa.c cpu-i370.c cpu-i386.c cpu-i860.c cpu-i960.c cpu-ia64.c cpu-ip2k.c cpu-iq2000.c cpu-k1om.c cpu-l1om.c cpu-lm32.c cpu-m10200.c cpu-m10300.c cpu-m32c.c cpu-m32r.c cpu-m68hc11.c cpu-m68hc12.c cpu-m68k.c cpu-m88k.c cpu-mcore.c cpu-mep.c cpu-microblaze.c cpu-mips.c cpu-mmix.c cpu-moxie.c cpu-msp430.c cpu-mt.c cpu-ns32k.c cpu-openrisc.c cpu-or32.c cpu-pdp11.c cpu-pj.c cpu-plugin.c cpu-powerpc.c cpu-rl78.c cpu-rs6000.c cpu-rx.c cpu-s390.c cpu-score.c cpu-sh.c cpu-sparc.c cpu-spu.c cpu-tic30.c cpu-tic4x.c cpu-tic54x.c cpu-tic6x.c cpu-tic80.c cpu-tilegx.c cpu-tilepro.c cpu-v850.c cpu-vax.c cpu-w65.c cpu-we32k.c cpu-xc16x.c cpu-xstormy16.c cpu-xtensa.c cpu-z80.c cpu-z8k.c libbfd.h linker.c ld : ChangeLog ldlang.c ldwrite.c ld/emulparams : elf32_x86_64.sh elf_i386.sh elf_i386_be.sh elf_i386_ldso.sh elf_i386_vxworks.sh elf_k1om.sh elf_l1om.sh elf_x86_64.sh ld/scripttempl : elf.sc ld/testsuite : ChangeLog ld/testsuite/ld-i386: tlsbindesc.dd tlsnopic.dd tlspic.dd ld/testsuite/ld-x86-64: tlsbin.dd tlsbindesc.dd tlspic.dd include : ChangeLog bfdlink.h Log message: Support arch-dependent fill bfd/ 2012-01-31 H.J. Lu <hongjiu.lu@intel.com> PR ld/13616 * archures.c (bfd_arch_info): Add fill. (bfd_default_arch_struct): Add bfd_arch_default_fill. (bfd_arch_default_fill): New. * configure.in: Set bfd version to 2.22.52. * configure: Regenerated. * cpu-alpha.c: Add bfd_arch_default_fill to bfd_arch_info initializer. * cpu-arc.c: Likewise. * cpu-arm.c: Likewise. * cpu-avr.c: Likewise. * cpu-bfin.c: Likewise. * cpu-cr16.c: Likewise. * cpu-cr16c.c: Likewise. * cpu-cris.c: Likewise. * cpu-crx.c: Likewise. * cpu-d10v.c: Likewise. * cpu-d30v.c: Likewise. * cpu-dlx.c: Likewise. * cpu-epiphany.c: Likewise. * cpu-fr30.c: Likewise. * cpu-frv.c: Likewise. * cpu-h8300.c: Likewise. * cpu-h8500.c: Likewise. * cpu-hppa.c: Likewise. * cpu-i370.c: Likewise. * cpu-i860.c: Likewise. * cpu-i960.c: Likewise. * cpu-ia64.c: Likewise. * cpu-ip2k.c: Likewise. * cpu-iq2000.c: Likewise. * cpu-lm32.c: Likewise. * cpu-m10200.c: Likewise. * cpu-m10300.c: Likewise. * cpu-m32c.c: Likewise. * cpu-m32r.c: Likewise. * cpu-m68hc11.c: Likewise. * cpu-m68hc12.c: Likewise. * cpu-m68k.c: Likewise. * cpu-m88k.c: Likewise. * cpu-mcore.c: Likewise. * cpu-mep.c: Likewise. * cpu-microblaze.c: Likewise. * cpu-mips.c: Likewise. * cpu-mmix.c: Likewise. * cpu-moxie.c: Likewise. * cpu-msp430.c: Likewise. * cpu-mt.c: Likewise. * cpu-ns32k.c: Likewise. * cpu-openrisc.c: Likewise. * cpu-or32.c: Likewise. * cpu-pdp11.c: Likewise. * cpu-pj.c: Likewise. * cpu-plugin.c: Likewise. * cpu-powerpc.c: Likewise. * cpu-rl78.c: Likewise. * cpu-rs6000.c: Likewise. * cpu-rx.c: Likewise. * cpu-s390.c: Likewise. * cpu-score.c: Likewise. * cpu-sh.c: Likewise. * cpu-sparc.c: Likewise. * cpu-spu.c: Likewise. * cpu-tic30.c: Likewise. * cpu-tic4x.c: Likewise. * cpu-tic54x.c: Likewise. * cpu-tic6x.c: Likewise. * cpu-tic80.c: Likewise. * cpu-tilegx.c: Likewise. * cpu-tilepro.c: Likewise. * cpu-v850.c: Likewise. * cpu-vax.c: Likewise. * cpu-w65.c: Likewise. * cpu-we32k.c: Likewise. * cpu-xc16x.c: Likewise. * cpu-xstormy16.c: Likewise. * cpu-xtensa.c: Likewise. * cpu-z80.c: Likewise. * cpu-z8k.c: Likewise. * cpu-i386.c: Include "libiberty.h". (bfd_arch_i386_fill): New. Add bfd_arch_i386_fill to bfd_arch_info initializer. * cpu-k1om.c: Add bfd_arch_i386_fill to bfd_arch_info initializer. * cpu-l1om.c: Likewise. * linker.c (default_data_link_order): Call abfd->arch_info->fill if fill size is 0. * bfd-in2.h: Regenerated. include/ 2012-01-31 H.J. Lu <hongjiu.lu@intel.com> PR ld/13616 * bfdlink.h (bfd_link_order): Update comments on data size. ld/ 2012-01-31 H.J. Lu <hongjiu.lu@intel.com> PR ld/13616 * emulparams/elf32_x86_64.sh: Remove NOP. * emulparams/elf_i386.sh: Likewise. * emulparams/elf_i386_be.sh: Likewise. * emulparams/elf_i386_ldso.sh: Likewise. * emulparams/elf_i386_vxworks.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/elf_x86_64.sh: Likewise. * ldlang.c (zero_fill): Initialized to 0. * ldwrite.c (build_link_order): Set data size to linker odrder size when they are the same. * scripttempl/elf.sc: Don't specify fill if NOP is undefined. ld/testsuite/ 2012-01-31 H.J. Lu <hongjiu.lu@intel.com> PR ld/13616 * ld-i386/tlsbindesc.dd: Update no-op padding. * ld-i386/tlsnopic.dd: Likewise. * ld-i386/tlspic.dd: Likewise. * ld-x86-64/tlsbin.dd: Likewise. * ld-x86-64/tlsbindesc.dd: Likewise. * ld-x86-64/tlspic.dd: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5594&r2=1.5595 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/archures.c.diff?cvsroot=src&r1=1.162&r2=1.163 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in2.h.diff?cvsroot=src&r1=1.555&r2=1.556 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/configure.diff?cvsroot=src&r1=1.357&r2=1.358 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/configure.in.diff?cvsroot=src&r1=1.305&r2=1.306 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-alpha.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-arc.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-arm.c.diff?cvsroot=src&r1=1.28&r2=1.29 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-avr.c.diff?cvsroot=src&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-bfin.c.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-cr16.c.diff?cvsroot=src&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-cr16c.c.diff?cvsroot=src&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-cris.c.diff?cvsroot=src&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-crx.c.diff?cvsroot=src&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-d10v.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-d30v.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-dlx.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-epiphany.c.diff?cvsroot=src&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-fr30.c.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-frv.c.diff?cvsroot=src&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-h8300.c.diff?cvsroot=src&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-h8500.c.diff?cvsroot=src&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-hppa.c.diff?cvsroot=src&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-i370.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-i386.c.diff?cvsroot=src&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-i860.c.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-i960.c.diff?cvsroot=src&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-ia64.c.diff?cvsroot=src&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-ip2k.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-iq2000.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-k1om.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-l1om.c.diff?cvsroot=src&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-lm32.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m10200.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m10300.c.diff?cvsroot=src&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m32c.c.diff?cvsroot=src&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m32r.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m68hc11.c.diff?cvsroot=src&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m68hc12.c.diff?cvsroot=src&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m68k.c.diff?cvsroot=src&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-m88k.c.diff?cvsroot=src&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-mcore.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-mep.c.diff?cvsroot=src&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-microblaze.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-mips.c.diff?cvsroot=src&r1=1.38&r2=1.39 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-mmix.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-moxie.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-msp430.c.diff?cvsroot=src&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-mt.c.diff?cvsroot=src&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-ns32k.c.diff?cvsroot=src&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-openrisc.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-or32.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-pdp11.c.diff?cvsroot=src&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-pj.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-plugin.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-powerpc.c.diff?cvsroot=src&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-rl78.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-rs6000.c.diff?cvsroot=src&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-rx.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-s390.c.diff?cvsroot=src&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-score.c.diff?cvsroot=src&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-sh.c.diff?cvsroot=src&r1=1.22&r2=1.23 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-sparc.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-spu.c.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tic30.c.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tic4x.c.diff?cvsroot=src&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tic54x.c.diff?cvsroot=src&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tic6x.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tic80.c.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tilegx.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tilepro.c.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-v850.c.diff?cvsroot=src&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-vax.c.diff?cvsroot=src&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-w65.c.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-we32k.c.diff?cvsroot=src&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-xc16x.c.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-xstormy16.c.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-xtensa.c.diff?cvsroot=src&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-z80.c.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-z8k.c.diff?cvsroot=src&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/libbfd.h.diff?cvsroot=src&r1=1.266&r2=1.267 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/linker.c.diff?cvsroot=src&r1=1.90&r2=1.91 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2402&r2=1.2403 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.381&r2=1.382 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldwrite.c.diff?cvsroot=src&r1=1.33&r2=1.34 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf32_x86_64.sh.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_i386.sh.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_i386_be.sh.diff?cvsroot=src&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_i386_ldso.sh.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_i386_vxworks.sh.diff?cvsroot=src&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_k1om.sh.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_l1om.sh.diff?cvsroot=src&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/emulparams/elf_x86_64.sh.diff?cvsroot=src&r1=1.23&r2=1.24 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/scripttempl/elf.sc.diff?cvsroot=src&r1=1.108&r2=1.109 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1487&r2=1.1488 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-i386/tlsbindesc.dd.diff?cvsroot=src&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-i386/tlsnopic.dd.diff?cvsroot=src&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-i386/tlspic.dd.diff?cvsroot=src&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsbin.dd.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlsbindesc.dd.diff?cvsroot=src&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-x86-64/tlspic.dd.diff?cvsroot=src&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/ChangeLog.diff?cvsroot=src&r1=1.561&r2=1.562 http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/bfdlink.h.diff?cvsroot=src&r1=1.93&r2=1.94
It is fixed for i386 and x86-64.
It's been pointed out that zeros are close enough to nops for ARM and Thumb. I'm not immediately concerned with other targets, so it might be OK to close this now unless the maintainers for other CPUs really intend to do something about it soon.
The i386 fix seems to break compatibility with older x86 CPUs, which cannot handle those multi byte NOPs. See bug 13675.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=22216541c1796e9e1331d6f4e16b03a6f02e7381 commit 22216541c1796e9e1331d6f4e16b03a6f02e7381 Author: Alan Modra <amodra@gmail.com> Date: Wed Oct 16 21:23:29 2019 +1030 PR13616, linker should pad executable sections with nops, not zeros This implements padding of orphan executable sections for PowerPC. Of course, the simple implementation of bfd_arch_ppc_nop_fill and removing the NOP definition didn't work, with powerpc64 hitting a testsuite failure linking to S-records. That's because the srec target is BFD_ENDIAN_UNKNOWN so the test of bfd_big_endian (abfd) in default_data_link_order therefore returned false, resulting in a little-endian nop pattern. The rest of the patch fixes that problem by adding a new field to bfd_link_info that can be used to determine actual endianness on targets like srec. PR 13616 include/ * bfdlink.h (struct bfd_link_info <big_endian>): New field. bfd/ * cpu-powerpc.c (bfd_arch_ppc_nop_fill): New function, use it for all ppc arch info. * linker.c (default_data_link_order): Pass info->big_endian to arch_info->fill function. ld/ * emulparams/elf64lppc.sh (NOP): Don't define. * emulparams/elf64ppc.sh (NOP): Don't define. * ldwrite.c (build_link_order): Use link_info.big_endian. Move code determining endian to use for data_statement to.. * ldemul.c (after_open_default): ..here. Set link_info.big_endian.
By my opinion, this problem is not ld, this problem is objdump, that not correctly dump of text section, by capture bytes outside of code, incorrectly count size of text section. This code size = 1 byte (ret), other bytes must be printed as .byte 0,0,0
Not so, this really is a ld problem. Some object files use a technique called code pasting, where pieces of a function are pasted together from multiple object files. If those pieces are in sections that are aligned greater than the smallest instruction size, then padding may be inserted between the pieces. ld must only insert nops for this scheme to work.
I know that some x86-32 systems appear to underalign .init and expect ld to pad with NOPs: https://bugs.llvm.org/show_bug.cgi?id=46364 If we show less mercy to such broken settings, traps are probably better than nops.