Skip to content

[llvm-objcopy] --gap-fill and 0-size sections #75837

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

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/ObjCopy/ELF/ELFObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ template <class ELFT> Error ELFWriter<ELFT>::finalize() {
Error BinaryWriter::write() {
SmallVector<const SectionBase *, 30> SectionsToWrite;
for (const SectionBase &Sec : Obj.allocSections()) {
if (Sec.Type != SHT_NOBITS)
if (Sec.Type != SHT_NOBITS && Sec.Size > 0)
SectionsToWrite.push_back(&Sec);
}

Expand Down
5 changes: 5 additions & 0 deletions llvm/test/tools/llvm-objcopy/ELF/gap-fill.test
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ Sections:
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x0108
Content: 'AABBCCDDFEDCBA'
- Name: .zero_size
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x0110
Size: 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this Size field is unnecessary, although if you want to leave it in for clarity, I won't object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'd like to leave it.

- Name: .space2
Type: Fill
Pattern: 'DC'
Expand Down