forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-objcopy] Add support for --strip-sections to remove all section…
… headers leaving only program headers and loadable segment data elf utils implements a particularly extreme form of stripping that I'd like to support. eu-strip has an option called "strip-sections" that removes all section headers and leaves only program headers and the segment data. I have implemented this option partly as a test but mainly because in Fuchsia we would like to use this option to minimize the size of our executables. The other strip options that are on my list include --strip-all and --strip-debug. This is a preliminary implementation that I'd like to start using in Fuchsia builds if possible. This change implements such a stripping option for llvm-objcopy Differential Revision: https://reviews.llvm.org/D38335 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315412 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
445025a
commit 0ac357a
Showing
4 changed files
with
114 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# RUN: yaml2obj %s > %t | ||
# RUN: llvm-objcopy --strip-sections %t %t2 | ||
# RUN: llvm-readobj -file-headers -program-headers %t2 | FileCheck %s | ||
# RUN: od -t x1 -j 4096 %t2 | FileCheck %s --check-prefix=DATA | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_EXEC | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] | ||
AddressAlign: 0x0000000000001000 | ||
Content: "DEADBEEF" | ||
ProgramHeaders: | ||
- Type: PT_LOAD | ||
Flags: [ PF_X, PF_R ] | ||
Sections: | ||
- Section: .text | ||
|
||
#DATA: 0010000 de ad be ef | ||
|
||
#CHECK: ElfHeader { | ||
#CHECK-NEXT: Ident { | ||
#CHECK-NEXT: Magic: (7F 45 4C 46) | ||
#CHECK-NEXT: Class: 64-bit (0x2) | ||
#CHECK-NEXT: DataEncoding: LittleEndian (0x1) | ||
#CHECK-NEXT: FileVersion: 1 | ||
#CHECK-NEXT: OS/ABI: SystemV (0x0) | ||
#CHECK-NEXT: ABIVersion: 0 | ||
#CHECK-NEXT: Unused: (00 00 00 00 00 00 00) | ||
#CHECK-NEXT: } | ||
#CHECK-NEXT: Type: Executable (0x2) | ||
#CHECK-NEXT: Machine: EM_X86_64 (0x3E) | ||
#CHECK-NEXT: Version: 1 | ||
#CHECK-NEXT: Entry: 0x0 | ||
#CHECK-NEXT: ProgramHeaderOffset: 0x40 | ||
#CHECK-NEXT: SectionHeaderOffset: 0x0 | ||
#CHECK-NEXT: Flags [ (0x0) | ||
#CHECK-NEXT: ] | ||
#CHECK-NEXT: HeaderSize: 64 | ||
#CHECK-NEXT: ProgramHeaderEntrySize: 56 | ||
#CHECK-NEXT: ProgramHeaderCount: 1 | ||
#CHECK-NEXT: SectionHeaderEntrySize: 64 | ||
#CHECK-NEXT: SectionHeaderCount: 0 | ||
#CHECK-NEXT: StringTableSectionIndex: 0 | ||
#CHECK-NEXT: } | ||
|
||
#CHECK: ProgramHeaders [ | ||
#CHECK-NEXT: ProgramHeader { | ||
#CHECK-NEXT: Type: PT_LOAD (0x1) | ||
#CHECK-NEXT: Offset: 0x1000 | ||
#CHECK-NEXT: VirtualAddress: 0x0 | ||
#CHECK-NEXT: PhysicalAddress: 0x0 | ||
#CHECK-NEXT: FileSize: 4 | ||
#CHECK-NEXT: MemSize: 4 | ||
#CHECK-NEXT: Flags [ (0x5) | ||
#CHECK-NEXT: PF_R (0x4) | ||
#CHECK-NEXT: PF_X (0x1) | ||
#CHECK-NEXT: ] | ||
#CHECK-NEXT: Alignment: 4096 | ||
#CHECK-NEXT: } | ||
#CHECK-NEXT:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters