Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get wrong .gnu.hash contents #983

Closed
wkisme opened this issue Oct 27, 2023 · 6 comments
Closed

Get wrong .gnu.hash contents #983

wkisme opened this issue Oct 27, 2023 · 6 comments
Assignees
Labels
duplicate Incomplete The issue is incomplete to be addressed

Comments

@wkisme
Copy link

wkisme commented Oct 27, 2023

Describe the bug
Just parse and write, the content of .gnu.hash is all zero

To Reproduce

cp /lib/x86_64-linux-gnu/libicuuc.so.70 .
python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lief
>>> lief.parse('libicuuc.so.70').write('libicuuc.so.70-1')
>>> exit()
objdump -s libicuuc.so.70-1 | grep .gnu.hash -A5
Contents of section .gnu.hash:
 02f0 05080000 59000000 00020000 0f000000  ....Y...........
 0300 00000000 00000000 00000000 00000000  ................
 0310 00000000 00000000 00000000 00000000  ................
 0320 00000000 00000000 00000000 00000000  ................
 0330 00000000 00000000 00000000 00000000  ................

Expected behavior
The content of .gnu.hash should be same as the original version of DSO.

prometheus@courage-machine:~/shrinkwrap/shrinkwrap$ objdump -s libicuuc.so.70 | grep .gnu.hash -A5
Contents of section .gnu.hash:
 02f0 05080000 59000000 00020000 0f000000  ....Y...........
 0300 08121008 3094c901 60a28202 84043028  ....0...`.....0(
 0310 005200c1 09100042 000382c0 10820280  .R.....B........
 0320 00205004 004e1120 00498001 10434808  . P..N. .I...CH.
 0330 1a003519 01460274 51010200 0464c080  ..5..F.tQ....d..

Environment (please complete the following information):

  • System and Version : Ubuntu 22.04.1 TLS
  • Target format ELF
  • LIEF commit version: 0.13.2-2d9855fc
    Additional context
prometheus@courage-machine:~/shrinkwrap/shrinkwrap$ cp /lib/x86_64-linux-gnu/libxml2.so.2 .
prometheus@courage-machine:~/shrinkwrap/shrinkwrap$ python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lief
>>> lief.parse('libxml2.so.2').write('libxml2.so.2-1')
>>> exit()
prometheus@courage-machine:~/shrinkwrap/shrinkwrap$ objdump -s libxml2.so.2 | grep .gnu.hash -A5
Contents of section .gnu.hash:
 02f0 07040000 84000000 00010000 0e000000  ................
 0300 1010c520 02080084 000c1008 84420a04  ... .........B..
 0310 22200064 191604c4 01204ba4 4020a110  " .d..... K.@ ..
 0320 00190215 00108404 14045500 80680038  ..........U..h.8
 0330 00018020 08109002 79582160 43002083  ... ....yX!`C. .
prometheus@courage-machine:~/shrinkwrap/shrinkwrap$ objdump -s libxml2.so.2-1 | grep .gnu.hash -A5
Contents of section .gnu.hash:
 02f0 07040000 84000000 00010000 0e000000  ................
 0300 1010c520 02080084 000c1008 84420a04  ... .........B..
 0310 22200064 191604c4 01204ba4 4020a110  " .d..... K.@ ..
 0320 00190215 00108404 14045500 80680038  ..........U..h.8
 0330 00018020 08109002 79582160 43002083  ... ....yX!`C. .
@romainthomas romainthomas added the Incomplete The issue is incomplete to be addressed label Oct 27, 2023
@romainthomas
Copy link
Member

Incomplete because: Missing libxml2.so.2 or libicuuc.so.70

@wkisme
Copy link
Author

wkisme commented Oct 27, 2023

sudo apt install libxml2, and you will get libxml2.so.2 and libicuuc.so.70

@romainthomas
Copy link
Member

What about attaching these files to the issue?

@romainthomas
Copy link
Member

Other remark: what is wrong by having a different .gnu.hash content?

@wkisme
Copy link
Author

wkisme commented Oct 27, 2023

Other remark: what is wrong by having a different .gnu.hash content?

The .gnu.hash content is for looking up symbols.
Maybe can't find corrected symbols, if the .gnu.hash content is different.

Following is an example that can't find symbol, which is in libicuuc.so.70 processed by lief.

prometheus@courage-machine:~/shrinkwrap/shrinkwrap$ ./emacs_zeta
./emacs_zeta: symbol lookup error: /home/prometheus/shrinkwrap/shrinkwrap/zeta-emacs/libxml2.so.2: undefined symbol: UCNV_FROM_U_CALLBACK_STOP_70

ldd /home/prometheus/shrinkwrap/shrinkwrap/zeta-emacs/libxml2.so.2 | grep libicuuc.so.70
        /home/prometheus/shrinkwrap/shrinkwrap/zeta-emacs/./libicuuc.so.70 (0x00007f208d205000)

nm -D /home/prometheus/shrinkwrap/shrinkwrap/zeta-emacs/./libicuuc.so.70 | grep UCNV_FROM_U_CALLBACK_STOP_70
00000000000d9610 T UCNV_FROM_U_CALLBACK_STOP_70

@romainthomas
Copy link
Member

Duplicated: #969

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Incomplete The issue is incomplete to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants