1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-29 11:24:36 +03:00
This commit is contained in:
Rui Ueyama 2021-03-14 16:17:32 +09:00
parent 1827c07dab
commit 640e9ba2d5
2 changed files with 9 additions and 1 deletions

View File

@ -203,7 +203,8 @@ static void create_synthetic_sections() {
add(out::got = new GotSection);
add(out::gotplt = new GotPltSection);
add(out::relplt = new RelPltSection);
add(out::strtab = new StrtabSection);
if (!config.strip_all)
add(out::strtab = new StrtabSection);
add(out::shstrtab = new ShstrtabSection);
add(out::plt = new PltSection);
add(out::pltgot = new PltGotSection);

View File

@ -109,6 +109,11 @@ ObjectFile::ObjectFile(MemoryMappedFile *mb, std::string archive_name,
is_alive = !is_in_lib;
}
static bool is_debug_section(const ElfShdr &shdr, std::string_view name) {
return !(shdr.sh_flags & SHF_ALLOC) &&
(name.starts_with(".debug") || name.starts_with(".zdebug"));
}
void ObjectFile::initialize_sections() {
// Read sections
for (i64 i = 0; i < elf_sections.size(); i++) {
@ -156,6 +161,8 @@ void ObjectFile::initialize_sections() {
std::string_view name = shstrtab.data() + shdr.sh_name;
if (name == ".note.gnu.property")
continue;
if (config.strip_all && is_debug_section(shdr, name))
continue;
this->sections[i] = InputSection::create(*this, &shdr, name, i);