diff options
author | Ian Lance Taylor <iant@google.com> | 2007-11-15 23:03:45 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-11-15 23:03:45 +0000 |
commit | 02d2ba740273e3f539501337eebf0c6007af0b4b (patch) | |
tree | d5f227a534ef7accd13c1aff4327c00935b7bbef /gold/layout.cc | |
parent | 557586a2002c600f50084e3ea9931393b44dbe46 (diff) | |
download | gdb-02d2ba740273e3f539501337eebf0c6007af0b4b.zip gdb-02d2ba740273e3f539501337eebf0c6007af0b4b.tar.gz gdb-02d2ba740273e3f539501337eebf0c6007af0b4b.tar.bz2 |
From Craig Silverstein: Add --strip-debug-gdb.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r-- | gold/layout.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gold/layout.cc b/gold/layout.cc index e4eda44..d3c5d69 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -98,6 +98,33 @@ is_prefix_of(const char* prefix, const char* str) return strncmp(prefix, str, strlen(prefix)) == 0; } +// Returns whether the given section is in the list of +// debug-sections-used-by-some-version-of-gdb. Currently, +// we've checked versions of gdb up to and including 6.7.1. + +static const char* gdb_sections[] = +{ ".debug_abbrev", + // ".debug_aranges", // not used by gdb as of 6.7.1 + ".debug_frame", + ".debug_info", + ".debug_line", + ".debug_loc", + ".debug_macinfo", + // ".debug_pubnames", // not used by gdb as of 6.7.1 + ".debug_ranges", + ".debug_str", +}; + +static inline bool +is_gdb_debug_section(const char* str) +{ + // We can do this faster: binary search or a hashtable. But why bother? + for (size_t i = 0; i < sizeof(gdb_sections)/sizeof(*gdb_sections); ++i) + if (strcmp(str, gdb_sections[i]) == 0) + return true; + return false; +} + // Whether to include this section in the link. template<int size, bool big_endian> @@ -134,6 +161,14 @@ Layout::include_section(Sized_relobj<size, big_endian>*, const char* name, || is_prefix_of(".stab", name)) return false; } + if (parameters->strip_debug_gdb() + && (shdr.get_sh_flags() & elfcpp::SHF_ALLOC) == 0) + { + // Debugging sections can only be recognized by name. + if (is_prefix_of(".debug", name) + && !is_gdb_debug_section(name)) + return false; + } return true; default: |