diff options
author | Dave Korn <dave.korn@artimi.com> | 2009-03-03 18:22:11 +0000 |
---|---|---|
committer | Dave Korn <dave.korn@artimi.com> | 2009-03-03 18:22:11 +0000 |
commit | 3efd345c3b8f1f91a1698023ac736f2648972d81 (patch) | |
tree | 4799c1fd81b722a3fdc73518103ca02a4fb1fa2b /ld/emultempl | |
parent | 6aa8e5c2ae66323abb1fb2f8b6c454305781aad2 (diff) | |
download | gdb-3efd345c3b8f1f91a1698023ac736f2648972d81.zip gdb-3efd345c3b8f1f91a1698023ac736f2648972d81.tar.gz gdb-3efd345c3b8f1f91a1698023ac736f2648972d81.tar.bz2 |
* emultempl/pe.em (debug_section_p): New bfd_map_over_sections hook.
(gld_${EMULATION_NAME}_after_open): Use it to iterate all sections
of all input BFDs, looking for debug info. Enable long section names
if any found.
* emultempl/pe.em (debug_section_p): Likewise.
(gld_${EMULATION_NAME}_after_open): Likewise.
* NEWS: Retrospectively adjust news announcement.
* ld.texinfo: Update documentation to mention new behaviour.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/pe.em | 30 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 30 |
2 files changed, 60 insertions, 0 deletions
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 46c4057..58ec809 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1043,6 +1043,13 @@ pr_sym (struct bfd_hash_entry *h, void *inf ATTRIBUTE_UNUSED) } #endif /* DLL_SUPPORT */ +static void +debug_section_p (bfd *abfd ATTRIBUTE_UNUSED, asection *sect, void *obj) +{ + int *found = (int *) obj; + if (strncmp (".debug_", sect->name, sizeof (".debug_") - 1) == 0) + *found = 1; +} static void gld_${EMULATION_NAME}_after_open (void) @@ -1076,6 +1083,29 @@ gld_${EMULATION_NAME}_after_open (void) pe_data (link_info.output_bfd)->pe_opthdr = pe; pe_data (link_info.output_bfd)->dll = init[DLLOFF].value; pe_data (link_info.output_bfd)->real_flags |= real_flags; + + /* At this point we must decide whether to use long section names + in the output or not. If the user hasn't explicitly specified + on the command line, we leave it to the default for the format + (object files yes, image files no), except if there is debug + information present; GDB relies on the long section names to + find it, so enable it in that case. */ + if (pe_use_coff_long_section_names < 0 && link_info.strip == strip_none) + { + /* Iterate over all sections of all input BFDs, checking + for any that begin 'debug_' and are long names. */ + LANG_FOR_EACH_INPUT_STATEMENT (is) + { + int found_debug = 0; + bfd_map_over_sections (is->the_bfd, debug_section_p, &found_debug); + if (found_debug) + { + pe_use_coff_long_section_names = 1; + break; + } + } + } + pe_output_file_set_long_section_names (link_info.output_bfd); #ifdef DLL_SUPPORT diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 0ab913b..13180a0 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1020,6 +1020,13 @@ pr_sym (struct bfd_hash_entry *h, void *inf ATTRIBUTE_UNUSED) } #endif /* DLL_SUPPORT */ +static void +debug_section_p (bfd *abfd ATTRIBUTE_UNUSED, asection *sect, void *obj) +{ + int *found = (int *) obj; + if (strncmp (".debug_", sect->name, sizeof (".debug_") - 1) == 0) + *found = 1; +} static void gld_${EMULATION_NAME}_after_open (void) @@ -1053,6 +1060,29 @@ gld_${EMULATION_NAME}_after_open (void) pe_data (link_info.output_bfd)->pe_opthdr = pep; pe_data (link_info.output_bfd)->dll = init[DLLOFF].value; pe_data (link_info.output_bfd)->real_flags |= real_flags; + + /* At this point we must decide whether to use long section names + in the output or not. If the user hasn't explicitly specified + on the command line, we leave it to the default for the format + (object files yes, image files no), except if there is debug + information present; GDB relies on the long section names to + find it, so enable it in that case. */ + if (pep_use_coff_long_section_names < 0 && link_info.strip == strip_none) + { + /* Iterate over all sections of all input BFDs, checking + for any that begin 'debug_' and are long names. */ + LANG_FOR_EACH_INPUT_STATEMENT (is) + { + int found_debug = 0; + bfd_map_over_sections (is->the_bfd, debug_section_p, &found_debug); + if (found_debug) + { + pep_use_coff_long_section_names = 1; + break; + } + } + } + pep_output_file_set_long_section_names (link_info.output_bfd); #ifdef DLL_SUPPORT |