diff options
author | Alan Modra <amodra@gmail.com> | 2017-02-28 10:38:51 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-03-01 07:22:54 +1030 |
commit | cc6b110b92572318bd32acf914b0fce9c4bb0a6f (patch) | |
tree | d1a6b2769f9b4992d99a8c1d2f7c78615e8bdd03 /gas/config/tc-nios2.h | |
parent | 3137ed4276c7bcbab65d18c6274145a6efd9f03f (diff) | |
download | gdb-cc6b110b92572318bd32acf914b0fce9c4bb0a6f.zip gdb-cc6b110b92572318bd32acf914b0fce9c4bb0a6f.tar.gz gdb-cc6b110b92572318bd32acf914b0fce9c4bb0a6f.tar.bz2 |
Nios2 dynobj handling fixes
A number of places in elf32-nios.c created dynamic sections but didn't
set the hash table dynobj. That meant we could have duplicate dynamic
sections connected to a number of bfds, so size_dynamic_sections
didn't properly discard or allocate contents.
Also, the entire set of dynamic sections was created in check_relocs
on seeing GOT relocs, when only .got related sections are needed,
probably done to hide segfaults later in finish_dynamic_sections.
The patch fixes these issues and makes the assembler emit errors when
nios2 lacks the necessary pc-relative relocs for subtraction
expressions, rather than silently generating bad code.
eg. ld-elf/merge. I've also tidied uses of elf32_nios2_hash_table and
elf_hash_table.
bfd/
PR 20995
* elf32-nios2.c (nios2_elf32_relocate_section): Use htab
rather than elf32_nios2_hash_table or elf_hash_table.
(create_got_section): Likewise.
(nios2_elf32_finish_dynamic_symbol): Likewise.
(nios2_elf32_adjust_dynamic_symbol): Likewise.
(nios2_elf32_size_dynamic_sections): Likewise.
(nios2_elf32_check_relocs): Delete dynobj, sgot, and srelgot
vars. Use htab equivalents directly instead. Don't create
all dynamic sections on needing just the GOT. Use a goto
rather than a fall-through with reloc test. Ensure
htab->dynobj is set when making dynamic sreloc section.
(nios2_elf32_finish_dynamic_sections): Delete dynobj, use htab
equivalent directly instead. Don't segfault on looking for
.dynamic when dynamic sections have not been created. Don't
segfault on .got.plt being discarded.
(nios2_elf32_size_dynamic_sections): Delete plt and got vars.
Don't set "relocs" on .rela.plt. Do handle .sbss. Delete
fixme and another not so relevant comment.
(nios2_elf_add_symbol_hook): Delete dynobj var. If not
already set, set hash table dynobj on creating .sbss.
gas/
* config/tc-nios2.h (TC_FORCE_RELOCATION_SUB_LOCAL): Define.
ld/
* testsuite/ld-elf/merge.d: xfail for nios.
Diffstat (limited to 'gas/config/tc-nios2.h')
-rw-r--r-- | gas/config/tc-nios2.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gas/config/tc-nios2.h b/gas/config/tc-nios2.h index 7c4c9dc..2b6f159 100644 --- a/gas/config/tc-nios2.h +++ b/gas/config/tc-nios2.h @@ -101,6 +101,14 @@ extern flagword nios2_elf_section_flags (flagword, int, int); #define DIFF_EXPR_OK +/* Don't allow the generic code to convert fixups involving the + subtraction of a label in the current section to pc-relative if we + don't have the necessary pc-relative relocation. */ +#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \ + (!((FIX)->fx_r_type == BFD_RELOC_16 \ + || (FIX)->fx_r_type == BFD_RELOC_NIOS2_LO16 \ + || (FIX)->fx_r_type == BFD_RELOC_NIOS2_HIADJ16)) + /* Nios2 ABI doesn't have 32-bit PCREL relocation, and, as relocations for CFI information will be in section other than .text, we can't use PC-biased relocs. */ |