diff --git a/object_file.cc b/object_file.cc index 7e89fde5..938e9876 100644 --- a/object_file.cc +++ b/object_file.cc @@ -840,8 +840,8 @@ void ObjectFile::convert_common_symbols() { if (!has_common_symbol) return; - static OutputSection *bss = - OutputSection::get_instance(".bss", SHT_NOBITS, SHF_WRITE | SHF_ALLOC); + static OutputSection *osec = + OutputSection::get_instance(".common", SHT_NOBITS, SHF_WRITE | SHF_ALLOC); for (i64 i = first_global; i < elf_syms.size(); i++) { if (!elf_syms[i].is_common()) @@ -864,8 +864,8 @@ void ObjectFile::convert_common_symbols() { shdr->sh_addralign = sym->esym->st_value; InputSection *isec = - new InputSection(*this, *shdr, ".bss", sections.size()); - isec->output_section = bss; + new InputSection(*this, *shdr, ".common", sections.size()); + isec->output_section = osec; sections.push_back(isec); sym->input_section = isec; diff --git a/test/common.sh b/test/common.sh index b0166e14..94987aa8 100755 --- a/test/common.sh +++ b/test/common.sh @@ -26,4 +26,7 @@ EOF clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/b.o $t/exe | grep -q '0 5 42' +readelf --sections $t/exe > $t/log +grep -q '.common .*NOBITS' $t/log + echo OK