Skip to content

Commit

Permalink
Set the basename of an output path to .gnu.version_d
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Jan 11, 2025
1 parent 48dd767 commit cf0d750
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/output-chunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2660,10 +2660,12 @@ void VerdefSection<E>::construct(Context<E> &ctx) {
aux->vda_name = ctx.dynstr->add_string(verstr);
};

if (!ctx.arg.soname.empty())
write(ctx.arg.soname, 1, VER_FLG_BASE);
else
write(ctx.arg.output, 1, VER_FLG_BASE);
std::string_view soname = ctx.arg.soname;
if (soname.empty()) {
std::filesystem::path path(ctx.arg.output);
soname = save_string(ctx, path.filename().string());
}
write(soname, 1, VER_FLG_BASE);

i64 idx = VER_NDX_LAST_RESERVED + 1;
for (std::string_view verstr : ctx.arg.version_definitions)
Expand Down
1 change: 1 addition & 0 deletions test/version-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ EOF
$CC -B. -shared -o $t/c.so -Wl,-version-script,$t/a.ver $t/b.s
readelf --version-info $t/c.so > $t/log

grep -Fq 'Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: c.so' $t/log
grep -Fq 'Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_x' $t/log

0 comments on commit cf0d750

Please sign in to comment.