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

When the size of the executable file is greater than UINT32_MAX, the section rewriting will fail. #571

Open
yinze00 opened this issue Nov 17, 2024 · 0 comments
Labels

Comments

@yinze00
Copy link

yinze00 commented Nov 17, 2024

Describe the bug

Binary filesize exceeded UINT32_MAX(0xffffffff) bytes, add-needed rewrite fails all entries
Steps To Reproduce
Our codebase's compilation target demo_service is quite large, and after the compilation is completed, we inject TensorFlow's custom operator library through patchelf, which takes effect when the program starts; one day, we suddenly noticed that patchelf failed, and the biggest difference we found was that the binary file size had increased significantly, exactly exceeding the limit of UINT32_MAX.

  • 3 months ago

2024/07/17 17:14:26 bin/demo_service 4273231224B

patchelf --add-needed libtf_ops_dyn.so demo_service

4273231224 < UINT32_MAX (4294967295) < 4312607552
works fine

  • now. 4312607552B

2024/07/29 15:55:20 bin/demo_service 4312607552B

patching ELF file 'demo_service'
DT_NULL index is 75
replacing section '.dynamic' with size 1312
replacing section '.dynstr' with size 53578732
this is an executable
using replaced section '.dynstr'
using replaced section '.dynamic'
last replaced is 28
looking at section '.interp'
replacing section '.interp' which is in the way
looking at section '.note.ABI-tag'
replacing section '.note.ABI-tag' which is in the way
looking at section '.note.gnu.build-id'
replacing section '.note.gnu.build-id' which is in the way
looking at section '.dynsym'
replacing section '.dynsym' which is in the way
looking at section '.dynstr'
looking at section '.gnu.hash'
first reserved offset/addr is 0x3a3d560/0x3e3d560
first page is 0x400000
needed space is 61070032
needed space is 61070088
needed pages is 2
changing alignment of program header 2 from 32768 to 4096
clearing first 61076096 bytes
rewriting section '.interp' from offset 0x270 (size 28) to offset 0x2e0 (size 28)
rewriting section '.note.ABI-tag' from offset 0x28c (size 32) to offset 0x300 (size 32)
rewriting section '.note.gnu.build-id' from offset 0x2ac (size 36) to offset 0x320 (size 36)
rewriting section '.dynsym' from offset 0x2d0 (size 7489200) to offset 0x348 (size 7489200)
rewriting section '.dynstr' from offset 0x724980 (size 53578714) to offset 0x7249f8 (size 53578732)
rewriting section '.dynamic' from offset 0x13bc31a8 (size 1296) to offset 0x3a3d5e8 (size 1312)
rewriting symbol table section 4
rewriting symbol table section 48
warning: entry 29229 bound 51 in symbol table refers to a non-existent section, skipping
warning: entry 24387 bound 51 in symbol table refers to a non-existent section, skipping
warning: entry 28524 bound 51 in symbol table refers to a non-existent section, skipping
warning: entry 24320 bound 51 in symbol table refers to a non-existent section, skipping
...
warning: entry 29806 bound 51 in symbol table refers to a non-existent section, skipping
writing viking.back

Expected behavior

A clear and concise description of what you expected to happen.

patchelf --version output

patchelf 0.12
@yinze00 yinze00 added the bug label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant