Bug ID: 34121
           Summary: LLD doesn't version linker script symbol aliases
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF

% cat sym.c
void f() {}

% cat sym.script
g = f;
VERSION { V1 { global: f; g; local: *; }; }

% clang -fPIC -c sym.c
% ld.lld -shared -o sym.o sym.script --no-undefined-version
ld.lld: error: version script assignment of 'V1' to symbol 'g' failed: symbol
not defined

ld.bfd handles this correctly. complains about having VERSION in a
linker script, but it works correctly if you pass it a separate version script.

I'll explain my use case, in case it helps with understanding the
motivation/suggesting alternatives. I'm renaming a large number of symbols in a
library (via changing an inline namespace), but I still need to preserve both
the old and new names for a while, for backward compatibility. The old and new
names are both versioned (I'm aware this is a pretty weird way to use symbol
versioning, but there's a long story there). As far as I know, I have three
ways to alias the old names to the new ones:

1. attribute((alias)). This requires the alias to be in the same translation
unit as the symbol being aliased, which isn't practical in my case.
2. Define the aliased functions myself to just call the new names. This works,
but it bloats up the text segment and introduces an extra jump. It also doesn't
work for data symbols.
3. Alias via the linker, using linker scripts or --defsym. This seems like the
ideal solution, but both approaches run into issues.

I have a small and (I think) pretty reasonable patch to make --defsym aliases
work with version scripts, but
makes that patch pretty useless for now. Linker script aliasing gets the symbol
table names correct, but linker script command processing also happens pretty
late, so getting that to play nice with version scripts might be more involved.

One workaround that I think will be good enough for me for now is to just drop
the local: *; from the version script. The source files are already annotated
with correct visibility annotations, so dropping that shouldn't produce any
unwanted exports. It's not super ideal in general though.

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to