From d5c928c05356b22af08450bf43b262ccc1b1d8ee Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Tue, 17 Jul 2018 20:04:53 +0100 Subject: 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) : Copy expression's `rel_from_abs' flag to the link hash. --- ld/ChangeLog | 6 ++++++ ld/ldexp.c | 1 + 2 files changed, 7 insertions(+) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index f5af858..0a0fa15 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2018-07-17 Maciej W. Rozycki + + * ldexp.c (exp_fold_tree_1) + : Copy expression's `rel_from_abs' flag to the + link hash. + 2018-07-12 Maciej W. Rozycki * testsuite/ld-mips-elf/mips-elf.exp (run_dump_test_abi) diff --git a/ld/ldexp.c b/ld/ldexp.c index 6fa251e..4ca812e 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -1200,6 +1200,7 @@ exp_fold_tree_1 (etree_type *tree) h->u.def.section = expld.result.section; h->linker_def = ! tree->assign.type.lineno; h->ldscript_def = 1; + h->rel_from_abs = expld.rel_from_abs; if (tree->assign.hidden) bfd_link_hide_symbol (link_info.output_bfd, &link_info, h); -- cgit v1.1