1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-24 00:43:18 +03:00

Place common symbols into .common section

This commit is contained in:
Rui Ueyama 2021-03-25 17:55:59 +09:00
parent e75708056e
commit 60029b028f
2 changed files with 7 additions and 4 deletions

View File

@ -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;

View File

@ -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