diff options
author | Alan Modra <amodra@gmail.com> | 2012-06-15 15:13:41 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2012-06-15 15:13:41 +0000 |
commit | d2667025dd30611514810c28bee9709e4623012a (patch) | |
tree | 7364422fa955cf289aef9008298bb0bc79394d65 /ld/emultempl | |
parent | 8e09ad05eda21f6772d6bcca1eb8b42e5d77be03 (diff) | |
download | gdb-d2667025dd30611514810c28bee9709e4623012a.zip gdb-d2667025dd30611514810c28bee9709e4623012a.tar.gz gdb-d2667025dd30611514810c28bee9709e4623012a.tar.bz2 |
ld/
* ldlang.h (lang_output_section_statement_type): Add after_end field.
(lang_abs_symbol_at_beginning_of, lang_abs_symbol_at_end_of): Delete.
(section_for_dot): Declare.
* ldlang.c (lang_size_sections_1): Correct comment.
(current_section): Move earlier.
(current_assign, prefer_next_section): New static vars.
(lang_do_assignments_1): Add found_end param. Detect _end
assignment to set found_end. Set os->after_end. Set above statics.
(lang_do_assignments): Adjust lang_do_assignments_1 call. Init
vars.
(section_for_dot): New function.
(lang_set_startof): Don't make an absolute symbol.
(lang_abs_symbol_at_beginning_of, lang_abs_symbol_at_end_of): Delete.
* ldexp.c (new_rel_from_abs): Use section_for_dot.
* emultempl/lnk960.em (symbol_at_beginning_of): New function.
(symbol_at_end_of): Likewise.
(lnk960_after_allocation): Use them.
* scripttempl/elf.sc: Precede OTHER_GOT_SYMBOLS with . = .; and
likewise before __bss_start.
ld/testsuite/
Update far too many tests.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/lnk960.em | 66 |
1 files changed, 62 insertions, 4 deletions
diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em index 7120329..e556d43 100644 --- a/ld/emultempl/lnk960.em +++ b/ld/emultempl/lnk960.em @@ -130,15 +130,73 @@ lnk960_after_parse (void) add_on (syslib_list, lang_input_file_is_search_file_enum); } +/* Create a symbol with the given name with the value of the + address of first byte of the section named. + + If the symbol already exists, then do nothing. */ + +static void +symbol_at_beginning_of (const char *secname, const char *name) +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE); + if (h == NULL) + einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); + + if (h->type == bfd_link_hash_new + || h->type == bfd_link_hash_undefined) + { + asection *sec; + + h->type = bfd_link_hash_defined; + + sec = bfd_get_section_by_name (link_info.output_bfd, secname); + if (sec == NULL) + sec = bfd_abs_section_ptr; + h->u.def.value = 0; + h->u.def.section = sec; + } +} + +/* Create a symbol with the given name with the value of the + address of the first byte after the end of the section named. + + If the symbol already exists, then do nothing. */ + +static void +symbol_at_end_of (const char *secname, const char *name) +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, TRUE, TRUE, TRUE); + if (h == NULL) + einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); + + if (h->type == bfd_link_hash_new + || h->type == bfd_link_hash_undefined) + { + asection *sec; + + h->type = bfd_link_hash_defined; + + sec = bfd_get_section_by_name (link_info.output_bfd, secname); + if (sec == NULL) + sec = bfd_abs_section_ptr; + h->u.def.value = sec->size; + h->u.def.section = sec; + } +} + static void lnk960_after_allocation (void) { if (!link_info.relocatable) { - lang_abs_symbol_at_end_of (".text", "_etext"); - lang_abs_symbol_at_end_of (".data", "_edata"); - lang_abs_symbol_at_beginning_of (".bss", "_bss_start"); - lang_abs_symbol_at_end_of (".bss", "_end"); + symbol_at_end_of (".text", "_etext"); + symbol_at_end_of (".data", "_edata"); + symbol_at_beginning_of (".bss", "_bss_start"); + symbol_at_end_of (".bss", "_end"); } } |