This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Committed: Add ELF hash table identifier to BFD


Hi Guys,

  I recently ran across a problem with a seg-fault in the x86_64 linker
  when it had been passed some i686 object files in a static library.  I
  eventually tracked it down to the fact that some code in elf32-i386.c
  was corrupting fields in the link hash table because it thought that
  it was an i386 link hash table when in fact it was a x86_64 link hash
  table.

  So I have created the attached patch to add a hash_table_id field to
  the elf_link_hash_table structure.  The patch also amends the backends
  so that if they have target specific fields added to the end of the
  structure they check the hash_table_id field before trying to access
  them.

  Tested without regressions on the following toolchains:

  alpha-linuxecoff alpha-linux-gnu alpha-unknown-freebsd4.7
  alpha-unknown-osf4.0 am33_2.0-linux-gnu arc-elf arm-aout arm-epoc-pe
  arm-netbsdelf arm-none-eabi arm-nto arm-symbianelf arm-vxworks
  arm-wince-pe avr-elf bfin-elf cr16-elf crx-elf cris-elf crisv32-elf
  d10v-elf d30v-elf dlx-elf fr30-elf frv-elf h8300-elf h8300-rtems
  hppa-linux-gnu hppa64-linux i370-linux i386-coff i386-lynxos
  i386-netware i386-rdos i586-aout i686-pc-beos i686-pc-cygwin
  i686-pc-elf i686-pc-linux-gnu i686-pc-linux-gnu-gold i686-pc-mingw32
  i860-stardent-elf ia64-x-freebsd5 ia64-linux ip2k-elf iq2000-elf
  lm32-rtems4.10 m32c-elf m32r-elf m68hc11-elf m68k-elf m68k-rtems
  m68k-uclinux mcore-elf mcore-pe mep-elf microblaze-elf mingw32-pe
  mips64-linux mips-ecoff mips-elf mips-sgi-irix6 mipsel-linux-gnu
  mipsisa32el-linux mips64vrel-elf mmix-mmixware mn10200-elf mn10300-elf
  msp430-elf mt-elf ns32k-netbsd openrisc-elf or32-elf pdp11-dec-aout
  pj-elf powerpc-eabisim powerpc-ibm-aix5.2.0 powerpc-nto
  powerpc-wrs-vxworks powerpc64-linux ppc-lynxos rs6000-aix4.3.3
  s390-linux s390x-ibm-tpf score-elf sh64-superh-linux-gnu sh-elf
  sh-linux sh-nto sh-symbianelf shl-unknown-netbsdelf1.6T
  sparc64-linux-gnu sparc64-netbsd sparc-linux-gnu spu-elf
  tic30-unknown-aout tic4x-coff tic54x-coff tx39-elf v850-elf
  vax-netbsdelf x86_64-linux x86_64-solaris2 xscale-elf xstormy16-elf
  xtensa-elf z8k-coff all all-64

Cheers
  Nick

bfd/ChangeLog
	* elf-bfd.h (emum elf_object_id): Rename to elf_target_id.  Add
	entries for other architectures.
	(struct elf_link_hash_table): Add hash_table_id field.
	(elf_hash_table_id): New accessor macro.
	* elflink.c (_bfd_elf_link_hash_table_init): Add target_id
	parameter.
	* elf-m10300.c (elf32_mn10300_hash_table): Check table id before
	returning cast pointer.
	(elf32_mn10300_link_hash_table_create): Identify new table as
	containing MN10300 extensions.
	(mn10300_elf_relax_section): Check pointer returned by
	elf32_mn10300_hash_table.
	* elf32-arm.c: Likewise, except using ARM extensions.
	* elf32-avr.c: Likewise, except using AVR extensions.
	* elf32-bfin.c: Likewise, except using BFIN extensions.
	* elf32-cris.c: Likewise, except using CRIS extensions.
	* elf32-frv.c: Likewise, except using FRV extensions.
	* elf32-hppa.c: Likewise, except using HPPA32 extensions.
	* elf32-i386.c: Likewise, except using I386 extensions.
	* elf32-lm32.c: Likewise, except using LM32 extensions.
	* elf32-m32r.c: Likewise, except using M32RM extensions.
	* elf32-m68hc11.c: Likewise, except using M68HC11 extensions.
	* elf32-m68hc1x.c: Likewise, except using M68HC11 extensions.
	* elf32-m68hc1x.h: Likewise, except using M68HC11 extensions.
	* elf32-m68k.c: Likewise, except using M68K extensions.
	* elf32-microblaze.c: Likewise, except using MICROBLAZE extensions.
	* elf32-ppc.c: Likewise, except using PPC32 extensions.
	* elf32-s390.c: Likewise, except using S390 extensions.
	* elf32-sh.c: Likewise, except using SH extensions.
	* elf32-spu.c: Likewise, except using SPU extensions.
	* elf32-xtensa.c: Likewise, except using XTENSA extensions.
	* elf64-alpha.c: Likewise, except using ALPHA extensions.
	* elf64-hppa.c: Likewise, except using HPPA64 extensions.
	* elf64-ppc.c: Likewise, except using PPC64 extensions.
	* elf64-s390.c: Likewise, except using S390 extensions.
	* elf64-x86-64.c: Likewise, except using X86_64 extensions.
	* elfxx-ia64.c: Likewise, except using IA64 extensions.
	* elfxx-mips.c: Likewise, except using MIPS extensions.
	* elfxx-sparc.c: Likewise, except using SPARC extensions.
	* elfxx-sparc.h: Likewise, except using SPARC extensions.
	* elf32-cr16.c (struct elf32_cr16_link_hash_table): Delete
	redundant structure.
	(elf32_cr16_hash_table): Delete unused macro.
	(elf32_cr16_link_hash_traverse): Delete unused macro.
	* elf32-score.c: Likewise.
	* elf32-score7.c: Likewise.
	* elf32-vax.c: Likewise.
	* elf64-sh64.c: Likewise.

ld/ChangeLog
	* emultempl/alphaelf.em: Update value expected from elf_object_id.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/mipself.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.

Attachment: elf-hash-table-id.patch.lzma
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]