Hi Ziyang,

On Sat, Jul 22, 2023 at 10:46:21AM +0000, chenziyang (C) wrote:
> Thanks for reply. First you may get libtarget_1.so from 
> https://github.com/JetXujing/xujing/blob/main/libtarget_1.so

Thanks. So using that trying to remove the .rustc section I do get:

eu-strip: Cannot remove symbol [7873] from allocated symbol table [3]

Note that this is a warning, not an error. The section is still
removed.

The issues is that in the original file the .rustc section is:
$ eu-readelf -S libtarget_1.so.orig | grep .rustc
[28] .rustc               PROGBITS     0000000000000000 006c71f2 00011e16  0    
    0   0  1

And symbol table 3 is:
$ eu-readelf -S libtarget_1.so.orig | grep '\[ 3\]'
[ 3] .dynsym              DYNSYM       000000000000d388 0000d388 00032598 24 A  
    4   1  8

Symbol 7873 in .dynsym is:
$ eu-readelf --symbols=.dynsym libtarget_1.so.orig | grep 7873:
 7873: 0000000000000000  73238 OBJECT  GLOBAL DEFAULT       28 
rust_metadata_target_af70f9bf599b19f0

Note that symbol refers to ndx (section) 28. That is out .rustc section.

Since .dynsym is an allocated symbol table it cannot simply remove
that symbol. But since it refers to a section that is about to be
removed it emits that warning and replaces the ndx (section) with
UNDEF:

$ eu-readelf --symbols=.dynsym libtarget_1.so.stripped | grep 7873:
 7873: 0000000000000000  73238 OBJECT  GLOBAL DEFAULT    UNDEF 
rust_metadata_target_af70f9bf599b19f0

> And I found the commit that trigger this error infor: 
> https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=7bf4b63a4980788e6c1969cae02f0483e79c069f;hp=4f7b5ba9624489b5a2f714569c29ef865d4dcd6f
> Is this error info an expected behavior?

Yes. It is an expected warning.

Cheers,

Mark

Reply via email to