diff options
author | Alan Modra <amodra@gmail.com> | 2014-07-08 15:24:06 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2014-07-08 19:42:03 +0930 |
commit | bffebb6ba5b4ddbca7353626d682f9f974584dbf (patch) | |
tree | 093877e73fca460e1b1f378024e210b46ddc1f00 /bfd | |
parent | 161ac41e03a819bc34e8c70a3fd1bc26f43858a2 (diff) | |
download | gdb-bffebb6ba5b4ddbca7353626d682f9f974584dbf.zip gdb-bffebb6ba5b4ddbca7353626d682f9f974584dbf.tar.gz gdb-bffebb6ba5b4ddbca7353626d682f9f974584dbf.tar.bz2 |
Copy st_other for linker script symbol assignments
This fixes a problem seen on powerpc64le ELFv2 when creating a
function symbol alias with ld --defsym. st_other needs to be copied
from the source symbol to the alias in order to set up the local entry
offset for the alias. I decided to make this change in the generic
ELF code rather than in elf64-ppc.c since it looks like other targets
that use st_other bits might benefit too.
bfd/
* elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other
bits from source to dest.
* linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment.
* targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>):
Likewise.
* bfd-in2.h: Regenerate.
ld/testsuite/
* ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test.
* ld-powerpc/powerpc.exp: Run it.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 9 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 3 | ||||
-rw-r--r-- | bfd/elflink.c | 19 | ||||
-rw-r--r-- | bfd/linker.c | 9 | ||||
-rw-r--r-- | bfd/targets.c | 3 |
5 files changed, 30 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index deed8ce..48280c4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2014-07-08 Alan Modra <amodra@gmail.com> + + * elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other + bits from source to dest. + * linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment. + * targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>): + Likewise. + * bfd-in2.h: Regenerate. + 2014-07-08 Jiong Wang <jiong.wang@arm.com> * elfnn-aarch64.c (elf_backend_rela_normal): Set to 1. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index ec19492..3886adc 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7084,7 +7084,8 @@ typedef struct bfd_target /* Indicate that we are only retrieving symbol values from this section. */ void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); - /* Copy the symbol type of a linker hash table entry. */ + /* Copy the symbol type and other attributes for a linker script + assignment of one symbol to another. */ #define bfd_copy_link_hash_symbol_type(b, t, f) \ BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) void (*_bfd_copy_link_hash_symbol_type) diff --git a/bfd/elflink.c b/bfd/elflink.c index ee80bcc..46d65f4 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -13044,17 +13044,24 @@ _bfd_elf_make_dynamic_reloc_section (asection * sec, return reloc_sec; } -/* Copy the ELF symbol type associated with a linker hash entry. */ +/* Copy the ELF symbol type and other attributes for a linker script + assignment from HSRC to HDEST. Generally this should be treated as + if we found a strong non-dynamic definition for HDEST (except that + ld ignores multiple definition errors). */ void -_bfd_elf_copy_link_hash_symbol_type (bfd *abfd ATTRIBUTE_UNUSED, - struct bfd_link_hash_entry * hdest, - struct bfd_link_hash_entry * hsrc) +_bfd_elf_copy_link_hash_symbol_type (bfd *abfd, + struct bfd_link_hash_entry *hdest, + struct bfd_link_hash_entry *hsrc) { - struct elf_link_hash_entry *ehdest = (struct elf_link_hash_entry *)hdest; - struct elf_link_hash_entry *ehsrc = (struct elf_link_hash_entry *)hsrc; + struct elf_link_hash_entry *ehdest = (struct elf_link_hash_entry *) hdest; + struct elf_link_hash_entry *ehsrc = (struct elf_link_hash_entry *) hsrc; + Elf_Internal_Sym isym; ehdest->type = ehsrc->type; ehdest->target_internal = ehsrc->target_internal; + + isym.st_other = ehsrc->other; + elf_merge_st_other (abfd, ehdest, &isym, TRUE, FALSE); } /* Append a RELA relocation REL to section S in BFD. */ diff --git a/bfd/linker.c b/bfd/linker.c index 483a0d4..f6ae4e2 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -861,14 +861,13 @@ _bfd_generic_link_just_syms (asection *sec, sec->output_offset = sec->vma; } -/* Copy the type of a symbol assiciated with a linker hast table entry. - Override this so that symbols created in linker scripts get their - type from the RHS of the assignment. +/* Copy the symbol type and other attributes for a linker script + assignment from HSRC to HDEST. The default implementation does nothing. */ void _bfd_generic_copy_link_hash_symbol_type (bfd *abfd ATTRIBUTE_UNUSED, - struct bfd_link_hash_entry * hdest ATTRIBUTE_UNUSED, - struct bfd_link_hash_entry * hsrc ATTRIBUTE_UNUSED) + struct bfd_link_hash_entry *hdest ATTRIBUTE_UNUSED, + struct bfd_link_hash_entry *hsrc ATTRIBUTE_UNUSED) { } diff --git a/bfd/targets.c b/bfd/targets.c index 83131d1..81a3695 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -478,7 +478,8 @@ BFD_JUMP_TABLE macros. . {* Indicate that we are only retrieving symbol values from this section. *} . void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); . -. {* Copy the symbol type of a linker hash table entry. *} +. {* Copy the symbol type and other attributes for a linker script +. assignment of one symbol to another. *} .#define bfd_copy_link_hash_symbol_type(b, t, f) \ . BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) . void (*_bfd_copy_link_hash_symbol_type) |