mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[llvm-objcopy] -O binary: consider SHT_NOBITS sections to be empty
This is consistent with BFD objcopy. Previously llvm objcopy would allocate space for SHT_NOBITS sections often resulting in enormous binary files. New test case (binary-paddr.test %t6). Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D95569
This commit is contained in:
parent
7761552c73
commit
019e9907bd
@ -183,3 +183,34 @@ Sections:
|
|||||||
- Name: .data
|
- Name: .data
|
||||||
Type: SHT_PROGBITS
|
Type: SHT_PROGBITS
|
||||||
Flags: [ SHF_ALLOC, SHF_WRITE ]
|
Flags: [ SHF_ALLOC, SHF_WRITE ]
|
||||||
|
|
||||||
|
## NOBITS sections should not appear in output.
|
||||||
|
# RUN: yaml2obj --docnum=6 %s -o %t6
|
||||||
|
# RUN: llvm-objcopy -O binary %t6 %t6.out
|
||||||
|
# RUN: od -A x -t x2 %t6.out | FileCheck %s --check-prefix=SKIPNOBITS --ignore-case
|
||||||
|
|
||||||
|
# SKIPNOBITS: 000000 c3c3 c3c3
|
||||||
|
# SKIPNOBITS-NEXT: 000004
|
||||||
|
|
||||||
|
--- !ELF
|
||||||
|
FileHeader:
|
||||||
|
Class: ELFCLASS64
|
||||||
|
Data: ELFDATA2LSB
|
||||||
|
Type: ET_EXEC
|
||||||
|
Machine: EM_X86_64
|
||||||
|
Sections:
|
||||||
|
- Name: .bss
|
||||||
|
Type: SHT_NOBITS
|
||||||
|
Flags: [ SHF_ALLOC ]
|
||||||
|
Address: 0x1000
|
||||||
|
AddressAlign: 0x1000
|
||||||
|
Size: 0x123
|
||||||
|
- Name: gap
|
||||||
|
Type: Fill
|
||||||
|
Size: 0xffd
|
||||||
|
- Name: .text
|
||||||
|
Type: SHT_PROGBITS
|
||||||
|
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||||
|
Address: 0x4000
|
||||||
|
AddressAlign: 0x1000
|
||||||
|
Content: "c3c3c3c3"
|
||||||
|
@ -2553,7 +2553,7 @@ Error BinaryWriter::finalize() {
|
|||||||
if (Sec.ParentSegment != nullptr)
|
if (Sec.ParentSegment != nullptr)
|
||||||
Sec.Addr =
|
Sec.Addr =
|
||||||
Sec.Offset - Sec.ParentSegment->Offset + Sec.ParentSegment->PAddr;
|
Sec.Offset - Sec.ParentSegment->Offset + Sec.ParentSegment->PAddr;
|
||||||
if (Sec.Size > 0)
|
if (Sec.Type != SHT_NOBITS && Sec.Size > 0)
|
||||||
MinAddr = std::min(MinAddr, Sec.Addr);
|
MinAddr = std::min(MinAddr, Sec.Addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user