| Summary: | objcopy --weaken-symbol does not weaken STB_GNU_UNIQUE symbols | ||
|---|---|---|---|
| Product: | binutils | Reporter: | Fangrui Song <maskray> |
| Component: | binutils | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Host: | Target: | ||
| Build: | Last reconfirmed: | ||
| Project(s) to access: | ssh public key: | ||
The master branch has been updated by Fangrui Song <maskray@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=260ecdcec427146f760836092a040f957427760b commit 260ecdcec427146f760836092a040f957427760b Author: Fangrui Song <i@maskray.me> Date: Wed Mar 16 09:38:37 2022 -0700 objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols PR binutils/28926 * objcopy.c (filter_symbols): Apply weaken to STB_GNU_UNIQUE symbols * NEWS: Mention feature. * testsuite/binutils-all/objcopy.exp (objcopy_test_symbol_manipulation): New test. * testsuite/binutils-all/weaken-gnu-unique.s: New. Fixed for 2.39 |
echo '.data; .type x, @gnu_unique_object; x:' | as - -o a.o objcopy -W x a.o readelf -Ws a.o The symbol 'x' remains STB_GNU_UNIQUE: Symbol table '.symtab' contains 2 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 OBJECT UNIQUE DEFAULT 2 x I think with the explicit request, it makes sense to weaken 'x'. The documentation for --weaken is: --weaken Change all global symbols in the file to be weak. This can be useful when building an object which will be linked against other objects using the -R option to the linker. This option is only effective when using an object file format which supports weak symbols. If we consider STB_GNU_UNIQUE "global", then --weaken probably should weaken STB_GNU_UNIQUE, too.