diff options
author | Maciej W. Rozycki <macro@mips.com> | 2018-07-17 20:04:53 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@mips.com> | 2018-07-17 20:04:53 +0100 |
commit | d5c928c05356b22af08450bf43b262ccc1b1d8ee (patch) | |
tree | c25959e98b71578bbd71f677ca7943335307eae5 /bfd | |
parent | 27724bad005cd734eb0b990205d315f8e2d3bd35 (diff) | |
download | gdb-d5c928c05356b22af08450bf43b262ccc1b1d8ee.zip gdb-d5c928c05356b22af08450bf43b262ccc1b1d8ee.tar.gz gdb-d5c928c05356b22af08450bf43b262ccc1b1d8ee.tar.bz2 |
LD: Export relative-from-absolute symbol marking to BFD
It is usually possible to tell absolute and ordinary symbols apart in
BFD throughout the link, by checking whether the section that owns the
symbol is absolute or not.
That however does not work for ordinary symbols defined in a linker
script outside an output section statement. Initially such symbols are
entered into to the link hash as absolute symbols, owned by the absolute
section. A flag is set in the internal linker expression defining such
symbols to tell the linker to convert them to section-relative ones in
the final phase of the link. That flag is however not accessible to BFD
linker code, including BFD target code in particular.
Add a flag to the link hash then to copy the information held in the
linker expression. Define a macro, `bfd_is_abs_symbol', for BFD code to
use where determining whether a symbol is absolute or ordinary is
required before the final link phase.
This macro will correctly identify the special `__ehdr_start' symbol as
ordinary throughout link, for example, even though early on it will be
assigned to the absolute section. Of course this does not let BFD code
identify what the symbol's ultimate section will be before the final
link phase has converted this symbol (in `update_definedness').
include/
* bfdlink.h (bfd_link_hash_entry): Add `rel_from_abs' member.
bfd/
* linker.c (bfd_is_abs_symbol): New macro.
* bfd-in2.h: Regenerate.
ld/
* ldexp.c (exp_fold_tree_1) <etree_assign, etree_provide>
<etree_provided>: Copy expression's `rel_from_abs' flag to the
link hash.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 11 | ||||
-rw-r--r-- | bfd/linker.c | 15 |
3 files changed, 30 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d4ae7ed..008d416 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2018-07-17 Maciej W. Rozycki <macro@mips.com> + + * linker.c (bfd_is_abs_symbol): New macro. + * bfd-in2.h: Regenerate. + 2018-07-16 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> * elf-bfd.h (elfcore_write_ppc_tar): Add prototype. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 93745bd..3414682 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7802,6 +7802,17 @@ bfd_boolean bfd_set_format (bfd *abfd, bfd_format format); const char *bfd_format_string (bfd_format format); /* Extracted from linker.c. */ +/* Return TRUE if the symbol described by a linker hash entry H + is going to be absolute. Linker-script defined symbols can be + converted from absolute to section-relative ones late in the + link. Use this macro to correctly determine whether the symbol + will actually end up absolute in output. */ +#define bfd_is_abs_symbol(H) \ + (((H)->type == bfd_link_hash_defined \ + || (H)->type == bfd_link_hash_defweak) \ + && bfd_is_abs_section ((H)->u.def.section) \ + && !(H)->rel_from_abs) + bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec); #define bfd_link_split_section(abfd, sec) \ diff --git a/bfd/linker.c b/bfd/linker.c index 6b4c8e5..9fee90d 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -484,7 +484,20 @@ _bfd_link_hash_table_init /* Look up a symbol in a link hash table. If follow is TRUE, we follow bfd_link_hash_indirect and bfd_link_hash_warning links to - the real symbol. */ + the real symbol. + +.{* Return TRUE if the symbol described by a linker hash entry H +. is going to be absolute. Linker-script defined symbols can be +. converted from absolute to section-relative ones late in the +. link. Use this macro to correctly determine whether the symbol +. will actually end up absolute in output. *} +.#define bfd_is_abs_symbol(H) \ +. (((H)->type == bfd_link_hash_defined \ +. || (H)->type == bfd_link_hash_defweak) \ +. && bfd_is_abs_section ((H)->u.def.section) \ +. && !(H)->rel_from_abs) +. +*/ struct bfd_link_hash_entry * bfd_link_hash_lookup (struct bfd_link_hash_table *table, |