diff options
author | Petr Machata <pmachata@redhat.com> | 2009-09-02 13:06:26 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2009-09-02 13:06:26 +0200 |
commit | f9e5a95b63c6e4879ea4ebfcbc1e81b4c5ffc56f (patch) | |
tree | 440aa08ac7e2df2f92a4b65fd56a037b1ec98f14 | |
parent | 8f91bc4048fd9e1d79610312a914c608136675a6 (diff) | |
download | elfutils-f9e5a95b63c6e4879ea4ebfcbc1e81b4c5ffc56f.tar.gz |
Don't emit empty .debug_str
(however unlikely that situation is)
-rw-r--r-- | libdw/c++/dwarf_output | 8 | ||||
-rw-r--r-- | src/writer.cc | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index 4e6f7400..ec6dc6a8 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -159,6 +159,11 @@ namespace elfutils ebl_strtabfree (_m_strtab); } + bool used () const + { + return _m_used; + } + Elf_Data *finalize (Elf_Scn *scn) { Elf_Data *data = elf_newdata (scn); @@ -171,16 +176,19 @@ namespace elfutils Ebl_Strent *add (char const *str) { + _m_used = true; return ebl_strtabadd (_m_strtab, str, 0); } Ebl_Strent *add (std::string const &str) { + _m_used = true; return ebl_strtabadd (_m_strtab, str.c_str (), str.length () + 1); } private: Ebl_Strtab *_m_strtab; + bool _m_used; }; class dwarf_output diff --git a/src/writer.cc b/src/writer.cc index e846f625..306bb5be 100644 --- a/src/writer.cc +++ b/src/writer.cc @@ -497,7 +497,7 @@ handle_elf (Elf *elf, size_t alloc_unit, debug_strtab); #define ADD_SECTION(NAME, TYPE, COMMAND) \ - { \ + do { \ shdr_info_t data_info (NAME, shst, TYPE, ++idx, newelf); \ assert (elf_ndxscn (data_info.newscn) == idx); \ \ @@ -505,7 +505,7 @@ handle_elf (Elf *elf, size_t alloc_unit, \ data_info.shdr.sh_size = COMMAND; \ shdr_info.push_back (data_info); \ - } + } while (false) ADD_SECTION (".debug_abbrev", SHT_PROGBITS, (writer.output_debug_abbrev (appender), @@ -515,8 +515,9 @@ handle_elf (Elf *elf, size_t alloc_unit, (writer.output_debug_info (appender), appender.size ())); - ADD_SECTION (".debug_str", SHT_STRTAB, - (debug_strtab.finalize (data_info.newscn)->d_size)); + if (debug_strtab.used ()) + ADD_SECTION (".debug_str", SHT_STRTAB, + debug_strtab.finalize (data_info.newscn)->d_size); ADD_SECTION (".shstrtab", SHT_STRTAB, shst.finalize (data_info.newscn)->d_size); |