rx-elf-strip ignores -K when using –strip-all on a static library
rx-elf-strip ignores -K when using –strip-all on a static library
I have a build that uses `–strip-all` followed by the set of symbols that intended to be public.
For other tool chains, this produces a static library with only the desired set of symbols exposed.
When using rx-elf-strip, it results in a library with all symbols removed; which is less than useful.
Is this a known defect or limitation? Is there a work-around option?
Hello,
Thank you for reaching out to us!
For the following simple test case, creating the archive and displaying the original symbols will show the following:
test.c:
int foo() {
return 3;
}
test2.c:
int bar() {
return 0;
}
rx-elf-gcc -c test.c test2.c
rx-elf-ar rcs libtest.a test.o test2.o
rx-elf-readelf -s libtest.a
File: libtest.a(test.o)
Symbol table '.symtab' contains 7 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FILE LOCAL DEFAULT ABS test.c
2: 00000000 0 SECTION LOCAL DEFAULT 1 P
3: 00000000 0 SECTION LOCAL DEFAULT 2 D_1
4: 00000000 0 SECTION LOCAL DEFAULT 3 B_1
5: 00000000 0 SECTION LOCAL DEFAULT 4 .comment
6: 00000000 11 FUNC GLOBAL DEFAULT 1 _bar
File: libtest.a(test2.o)
Symbol table '.symtab' contains 7 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FILE LOCAL DEFAULT ABS test2.c
2: 00000000 0 SECTION LOCAL DEFAULT 1 P
3: 00000000 0 SECTION LOCAL DEFAULT 2 D_1
4: 00000000 0 SECTION LOCAL DEFAULT 3 B_1
5: 00000000 0 SECTION LOCAL DEFAULT 4 .comment
6: 00000000 11 FUNC GLOBAL DEFAULT 1 _foo
After stripping all but foo, the following symbols remain:
rx-elf-strip -s libtest.a -o libtest_stripped.a -K _foo
rx-elf-readelf -s libtest_stripped.a
File: libtest_stripped.a(test.o)
File: libtest_stripped.a(test2.o)
Symbol table '.symtab' contains 2 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 11 FUNC GLOBAL DEFAULT 1 _foo
This is the correct behavior. If this is not what you are experiencing please provide us a minimal reproducible example: objects or archives before and after stripping and the exact command used to strip the symbols.
Best regards,
The Open Source Tools Team

English