X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Femultempl%2Flnk960.em;h=4a2bd72f59ea0acb4f07be8f65b6193abb5f372a;hb=99aefae6818be07a77739e0366121f2032916d9c;hp=1c820655cf5419d7706b17f7d5ee0c1fec8768bb;hpb=5e797c2c670d8fe04e417043214c0a1843a18aa3;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em index 1c820655cf..4a2bd72f59 100644 --- a/ld/emultempl/lnk960.em +++ b/ld/emultempl/lnk960.em @@ -1,30 +1,30 @@ # This shell script emits a C file. -*- C -*- # It does some substitutions. -cat >e${EMULATION_NAME}.c <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) + if (!bfd_link_relocatable (&link_info)) { - 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"); } } @@ -188,7 +246,7 @@ lnk960_set_output_arch (void) break; } } - bfd_set_arch_mach (output_bfd, ldfile_output_architecture, + bfd_set_arch_mach (link_info.output_bfd, ldfile_output_architecture, ldfile_output_machine); } @@ -209,22 +267,22 @@ static char * lnk960_get_script (int *isfile) EOF -if test -n "$COMPILE_IN" +if test x"$COMPILE_IN" = xyes then # Scripts compiled in. # sed commands to quote an ld script as a C string. sc="-f stringify.sed" -cat >>e${EMULATION_NAME}.c <> e${EMULATION_NAME}.c -echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c +echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c @@ -237,13 +295,13 @@ echo '; }' >> e${EMULATION_NAME}.c else # Scripts read from the filesystem. -cat >>e${EMULATION_NAME}.c <>e${EMULATION_NAME}.c <