* Committed: Add ELF hash table identifier to BFD
@ 2010-02-04 9:14 Nick Clifton
2010-02-04 9:53 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2010-02-04 9:14 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 4866 bytes --]
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 #2: elf-hash-table-id.patch.lzma --]
[-- Type: application/octet-stream, Size: 33307 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Committed: Add ELF hash table identifier to BFD
2010-02-04 9:14 Committed: Add ELF hash table identifier to BFD Nick Clifton
@ 2010-02-04 9:53 ` Andreas Schwab
2010-02-04 10:16 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2010-02-04 9:53 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
Nick Clifton <nickc@redhat.com> writes:
> 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.
What about the null pointer references?
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Committed: Add ELF hash table identifier to BFD
2010-02-04 9:53 ` Andreas Schwab
@ 2010-02-04 10:16 ` Nick Clifton
2010-02-04 10:28 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2010-02-04 10:16 UTC (permalink / raw)
To: Andreas Schwab; +Cc: binutils
Hi Andreas,
>> 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.
>
> What about the null pointer references?
I added code to check for these.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Committed: Add ELF hash table identifier to BFD
2010-02-04 10:16 ` Nick Clifton
@ 2010-02-04 10:28 ` Andreas Schwab
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2010-02-04 10:28 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
Nick Clifton <nickc@redhat.com> writes:
> Hi Andreas,
>
>>> 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.
>>
>> What about the null pointer references?
>
> I added code to check for these.
Where? I cannot find anything that checks the value of
elf_m68k_hash_table.
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-04 10:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-04 9:14 Committed: Add ELF hash table identifier to BFD Nick Clifton
2010-02-04 9:53 ` Andreas Schwab
2010-02-04 10:16 ` Nick Clifton
2010-02-04 10:28 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).