diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-09-14 11:41:58 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-09-14 12:29:29 -0700 |
commit | 5e5e02aeca4a6edccbf11b5f900d95bba59b9932 (patch) | |
tree | 75d5fa026dbb595fa819238129eb9cdb9e46b868 /bfd/elf64-x86-64.c | |
parent | 26e53f3eace35cabeec4559d417df99a48f6477a (diff) | |
download | gdb-5e5e02aeca4a6edccbf11b5f900d95bba59b9932.zip gdb-5e5e02aeca4a6edccbf11b5f900d95bba59b9932.tar.gz gdb-5e5e02aeca4a6edccbf11b5f900d95bba59b9932.tar.bz2 |
x86: Cache section contents and relocations
bfd/
PR ld/22135
* elf32-i386.c (elf_i386_convert_load_reloc): Add an argument
to indicate if conversion is performed.
(elf_i386_check_relocs): Cache section contents and relocations
if conversion is performed.
* elf64-x86-64.c (elf_x86_64_check_relocs): Cache section
contents and relocations if conversion is performed.
ld/
PR ld/22135
* testsuite/ld-i386/i386.exp: Run pr22135.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22135.d: New file.
* testsuite/ld-i386/pr22135.s: Likewise.
* testsuite/ld-x86-64/pr22135.d: Likewise.
* testsuite/ld-x86-64/pr22135.s: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r-- | bfd/elf64-x86-64.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 4371a16..84a2603 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1780,6 +1780,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Rela *rel_end; asection *sreloc; bfd_byte *contents; + bfd_boolean converted; if (bfd_link_relocatable (info)) return TRUE; @@ -1814,6 +1815,8 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, symtab_hdr = &elf_symtab_hdr (abfd); sym_hashes = elf_sym_hashes (abfd); + converted = FALSE; + sreloc = NULL; rel_end = relocs + sec->reloc_count; @@ -1931,6 +1934,9 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, irel, h, &converted_reloc, info)) goto error_return; + + if (converted_reloc) + converted = TRUE; } if (! elf_x86_64_tls_transition (info, abfd, sec, contents, @@ -2306,15 +2312,20 @@ do_size: if (elf_section_data (sec)->this_hdr.contents != contents) { - if (!info->keep_memory) + if (!converted && !info->keep_memory) free (contents); else { - /* Cache the section contents for elf_link_input_bfd. */ + /* Cache the section contents for elf_link_input_bfd if any + load is converted or --no-keep-memory isn't used. */ elf_section_data (sec)->this_hdr.contents = contents; } } + /* Cache relocations if any load is converted. */ + if (elf_section_data (sec)->relocs != relocs && converted) + elf_section_data (sec)->relocs = (Elf_Internal_Rela *) relocs; + return TRUE; error_return: |