diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-01-11 08:04:27 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-01-11 08:04:27 -0800 |
commit | 9d1d54d5a7e3b634895e6e434646c706eb55c082 (patch) | |
tree | 1786be2d2d4607f8a33cede8c25bb57519218ebe /bfd | |
parent | b2fb95e006c29e2cbe4b30523879fe3640f906ad (diff) | |
download | gdb-9d1d54d5a7e3b634895e6e434646c706eb55c082.zip gdb-9d1d54d5a7e3b634895e6e434646c706eb55c082.tar.gz gdb-9d1d54d5a7e3b634895e6e434646c706eb55c082.tar.bz2 |
Only discard space for pc-relative relocs symbols
When building PIE, we should only discard space for pc-relative relocs
symbols which turn out to need copy relocs.
bfd/
PR ld/17827
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): For PIE,
only discard space for pc-relative relocs symbols which turn
out to need copy relocs.
ld/testsuite/
PR ld/17827
* ld-x86-64/pr17689.out: Updated.
* ld-x86-64/pr17689b.S: Likewise.
* ld-x86-64/pr17827.rd: New file.
* ld-x86-64/x86-64.exp: Run PR ld/17827 test.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 16 |
2 files changed, 20 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 70b138b..234d559 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2015-01-11 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/17827 + * elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): For PIE, + only discard space for pc-relative relocs symbols which turn + out to need copy relocs. + 2015-01-09 Nick Clifton <nickc@redhat.com> * tekhex.c (getvalue): Fix thinko in test for correct extraction diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 581ee17..6b7d3c9 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2742,13 +2742,23 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) && ! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } - /* For PIE, discard space for relocs against symbols which - turn out to need copy relocs. */ + /* For PIE, discard space for pc-relative relocs against + symbols which turn out to need copy relocs. */ else if (info->executable && (h->needs_copy || eh->needs_copy) && h->def_dynamic && !h->def_regular) - eh->dyn_relocs = NULL; + { + struct elf_dyn_relocs **pp; + + for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) + { + if (p->pc_count != 0) + *pp = p->next; + else + pp = &p->next; + } + } } } else if (ELIMINATE_COPY_RELOCS) |