mirror of
https://github.com/rui314/mold.git
synced 2024-12-24 17:01:50 +03:00
Place common symbols into .common section
This commit is contained in:
parent
e75708056e
commit
60029b028f
@ -840,8 +840,8 @@ void ObjectFile::convert_common_symbols() {
|
|||||||
if (!has_common_symbol)
|
if (!has_common_symbol)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static OutputSection *bss =
|
static OutputSection *osec =
|
||||||
OutputSection::get_instance(".bss", SHT_NOBITS, SHF_WRITE | SHF_ALLOC);
|
OutputSection::get_instance(".common", SHT_NOBITS, SHF_WRITE | SHF_ALLOC);
|
||||||
|
|
||||||
for (i64 i = first_global; i < elf_syms.size(); i++) {
|
for (i64 i = first_global; i < elf_syms.size(); i++) {
|
||||||
if (!elf_syms[i].is_common())
|
if (!elf_syms[i].is_common())
|
||||||
@ -864,8 +864,8 @@ void ObjectFile::convert_common_symbols() {
|
|||||||
shdr->sh_addralign = sym->esym->st_value;
|
shdr->sh_addralign = sym->esym->st_value;
|
||||||
|
|
||||||
InputSection *isec =
|
InputSection *isec =
|
||||||
new InputSection(*this, *shdr, ".bss", sections.size());
|
new InputSection(*this, *shdr, ".common", sections.size());
|
||||||
isec->output_section = bss;
|
isec->output_section = osec;
|
||||||
sections.push_back(isec);
|
sections.push_back(isec);
|
||||||
|
|
||||||
sym->input_section = isec;
|
sym->input_section = isec;
|
||||||
|
@ -26,4 +26,7 @@ EOF
|
|||||||
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/b.o
|
clang -fuse-ld=`pwd`/../mold -o $t/exe $t/a.o $t/b.o
|
||||||
$t/exe | grep -q '0 5 42'
|
$t/exe | grep -q '0 5 42'
|
||||||
|
|
||||||
|
readelf --sections $t/exe > $t/log
|
||||||
|
grep -q '.common .*NOBITS' $t/log
|
||||||
|
|
||||||
echo OK
|
echo OK
|
||||||
|
Loading…
Reference in New Issue
Block a user