mirror of
https://github.com/rui314/mold.git
synced 2024-09-17 16:09:43 +03:00
Fix non-deterministic behavior
This commit is contained in:
parent
7434465334
commit
6463a7c48a
@ -623,19 +623,19 @@ void create_output_sections(Context<E> &ctx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto get_or_insert = [&] {
|
||||
OutputSectionKey key = get_output_section_key(ctx, *isec);
|
||||
|
||||
if (auto it = cache.find(key); it != cache.end()) {
|
||||
isec->output_section = it->second;
|
||||
continue;
|
||||
}
|
||||
if (auto it = cache.find(key); it != cache.end())
|
||||
return it->second;
|
||||
|
||||
auto get_or_insert = [&] {
|
||||
{
|
||||
std::shared_lock lock(mu);
|
||||
if (auto it = map.find(key); it != map.end())
|
||||
if (auto it = map.find(key); it != map.end()) {
|
||||
cache.insert({key, it->second});
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<OutputSection<E>> osec =
|
||||
std::make_unique<OutputSection<E>>(key.name, key.type);
|
||||
@ -646,13 +646,15 @@ void create_output_sections(Context<E> &ctx) {
|
||||
|
||||
if (inserted)
|
||||
ctx.osec_pool.emplace_back(std::move(osec));
|
||||
cache.insert({key, it->second});
|
||||
return ret;
|
||||
};
|
||||
|
||||
OutputSection<E> *osec = get_or_insert();
|
||||
osec->sh_flags |= sh_flags & ~SHF_GROUP;
|
||||
sh_flags &= ~SHF_GROUP;
|
||||
if ((osec->sh_flags & sh_flags) != sh_flags)
|
||||
osec->sh_flags |= sh_flags;
|
||||
isec->output_section = osec;
|
||||
cache.insert({key, osec});
|
||||
}
|
||||
});
|
||||
|
||||
|
24
test/elf/section-attributes.sh
Executable file
24
test/elf/section-attributes.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
. $(dirname $0)/common.inc
|
||||
|
||||
cat <<EOF | $CC -o $t/a.o -c -xassembler -
|
||||
.section .foobar,"aw"
|
||||
.ascii "foo\0"
|
||||
EOF
|
||||
|
||||
cat <<EOF | $CC -o $t/b.o -c -xassembler -
|
||||
.section .foobar,"a"
|
||||
.ascii "bar\0"
|
||||
EOF
|
||||
|
||||
cat <<EOF | $CC -o $t/c.o -c -xassembler -
|
||||
.section .foobar,"ax"
|
||||
.ascii "bar\0"
|
||||
EOF
|
||||
|
||||
cat <<EOF | $CC -o $t/d.o -c -xc -
|
||||
int main() {}
|
||||
EOF
|
||||
|
||||
$CC -B. -o $t/exe $t/a.o $t/b.o $t/c.o $t/d.o
|
||||
readelf -W --sections $t/exe | grep -q 'foobar.*WAX'
|
Loading…
Reference in New Issue
Block a user