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

[llvm-strip] llvm-strip doesn't remove empty group sections #97139

Closed
chestnykh opened this issue Jun 29, 2024 · 2 comments · Fixed by #97141
Closed

[llvm-strip] llvm-strip doesn't remove empty group sections #97139

chestnykh opened this issue Jun 29, 2024 · 2 comments · Fixed by #97141

Comments

@chestnykh
Copy link
Contributor

chestnykh commented Jun 29, 2024

gcc -g3 produces ELF objects that contains group sections with .debug_ sections inside.
If such ELF object will be processed with llvm-strip --strip-debug then the output ELF will contain

group section [ 1] .group [foo_grp] contains 0 sections:.

Such objects cannot be processed for example by GNU binutils (file format not recognized).
The Full test case:

echo 'int main(){return 0;}' > test.c
gcc -g3 -c test.c -o test.o
llvm-strip --strip-debug test.o -o test.stripped.o
ld.bfd test.stripped.o -o test
test.stripped.o: file not recognized: file format not recognized

chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 29, 2024
Currently `llvm-strip` in `--strip-debug` mode doesn't remove
such sections. This behavior can lead to incompatibilities
with GNU binutils (for examples ld.bfd cannot process
the object file contains empty .group section).
The ELF object that contains group section with `.debug_*`
sections inside can be obtained by `gcc -g3`.
Fix llvm#97139
chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 29, 2024
Currently `llvm-strip` in `--strip-debug` mode doesn't remove
such sections. This behavior can lead to incompatibilities
with GNU binutils (for examples ld.bfd cannot process
the object file contains empty .group section).
The ELF object that contains group section with `.debug_*`
sections inside can be obtained by `gcc -g3`.
Fix llvm#97139
@llvmbot
Copy link
Member

llvmbot commented Jun 29, 2024

@llvm/issue-subscribers-tools-llvm-objcopy-strip

Author: Dmitriy Chestnykh (chestnykh)

`gcc -g3` produces ELF objects that contains group sections with `.debug_` sections inside. If such ELF object will be processed with `llvm-strip --strip-debug` then the output ELF will contain

group section [ 1] .group [foo_grp] contains 0 sections:.

Such objects cannot be processed for example by GNU binutils (file format not recognized).
The Full test case:

echo 'int main(){return 0;}' > test.c
gcc -g3 -c test.c -o test.o
llvm-strip --strip-debug test.o -o test.stripped.o
ld.bfd test.stripped.o -o test
test.stripped.o: file not recognized: file format not recognized

chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 29, 2024
Currently `llvm-strip` in `--strip-debug` mode doesn't remove
such sections. This behavior can lead to incompatibilities
with GNU binutils (for examples ld.bfd cannot process
the object file contains empty .group section).
The ELF object that contains group section with `.debug_*`
sections inside can be obtained by `gcc -g3`.
Fix llvm#97139
chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 29, 2024
Currently `llvm-strip` in `--strip-debug` mode doesn't remove
such sections. This behavior can lead to incompatibilities
with GNU binutils (for examples ld.bfd cannot process
the object file contains empty .group section).
The ELF object that contains group section with `.debug_*`
sections inside can be obtained by `gcc -g3`.
Fix llvm#97139
chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 30, 2024
Currently llvm-strip in --strip-debug mode doesn't remove such sections.
This behavior can lead to incompatibilities with GNU binutils
(for examples ld.bfd cannot process the object file contains empty .group section).
The ELF object that contains group section
with .debug_* sections inside can be obtained by gcc -g3.
Fix llvm#97139
chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 30, 2024
Currently llvm-strip in --strip-debug mode doesn't remove such sections.
This behavior can lead to incompatibilities with GNU binutils
(for examples ld.bfd cannot process the object file contains empty .group section).
The ELF object that contains group section
with .debug_* sections inside can be obtained by gcc -g3.
Fix llvm#97139
chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jun 30, 2024
Currently llvm-strip in --strip-debug mode doesn't remove such sections.
This behavior can lead to incompatibilities with GNU binutils
(for examples ld.bfd cannot process the object file contains empty .group section).
The ELF object that contains group section
with .debug_* sections inside can be obtained by gcc -g3.
Fix llvm#97139
@MaskRay
Copy link
Member

MaskRay commented Jul 6, 2024

I happened to notice that GNU ld reported file not recognized: file format not recognized with empty section groups 4 and pinged https://sourceware.org/bugzilla/show_bug.cgi?id=20520 4 weeks ago.

Alan Modra fixed the issue 2 weeks ago for binutils 2.43 :)

chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jul 6, 2024
Currently llvm-strip in --strip-debug mode doesn't remove such sections.
This behavior can lead to incompatibilities with GNU binutils
(for examples ld.bfd cannot process the object file contains empty .group section).
The ELF object that contains group section
with .debug_* sections inside can be obtained by gcc -g3.
Fix llvm#97139
@MaskRay MaskRay closed this as completed in 359c64f Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants