forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 16
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 --set-section-alignment
Fixes PR43181. This option was recently added to GNU objcopy (binutils PR24942). `llvm-objcopy -I binary -O elf64-x86-64 --set-section-alignment .data=8` can set the alignment of .data. Reviewed By: grimar, jhenderson, rupprecht Differential Revision: https://reviews.llvm.org/D67656 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373461 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
9 changed files
with
119 additions
and
11 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# RUN: yaml2obj %s -o %t | ||
|
||
# RUN: llvm-objcopy --set-section-alignment .foo=4 --set-section-alignment .bar=0x5 \ | ||
# RUN: --set-section-alignment .baz=0 %t %t.2 | ||
# RUN: llvm-readobj --sections %t.2 | FileCheck --check-prefix=CHECK %s | ||
|
||
# CHECK: Name: .foo | ||
# CHECK: AddressAlignment: | ||
# CHECK-SAME: 4{{$}} | ||
# CHECK: Name: .bar | ||
# CHECK: AddressAlignment: | ||
# CHECK-SAME: 5{{$}} | ||
# CHECK: Name: .baz | ||
# CHECK: AddressAlignment: | ||
# CHECK-SAME: 0{{$}} | ||
|
||
## If a section is specified multiple times, the last wins. | ||
# RUN: llvm-objcopy --set-section-alignment .foo=4 --set-section-alignment=.foo=7 %t %t.3 | ||
# RUN: llvm-readobj --sections %t.3 | FileCheck --check-prefix=MULTI %s | ||
|
||
# MULTI: Name: .foo | ||
# MULTI: AddressAlignment: | ||
# MULTI-SAME: 7{{$}} | ||
|
||
## Ignore the option if the section does not exist. | ||
# RUN: llvm-objcopy --set-section-alignment .not_exist=4 %t.3 %t.4 | ||
# RUN: cmp %t.3 %t.4 | ||
|
||
# RUN: not llvm-objcopy --set-section-alignment=.foo %t /dev/null 2>&1 | \ | ||
# RUN: FileCheck --check-prefix=MISSING-EQUAL %s | ||
# MISSING-EQUAL: error: bad format for --set-section-alignment: missing '=' | ||
|
||
# RUN: not llvm-objcopy --set-section-alignment==4 %t /dev/null 2>&1 | \ | ||
# RUN: FileCheck --check-prefix=MISSING-SECTION %s | ||
# MISSING-SECTION: error: bad format for --set-section-alignment: missing section name | ||
|
||
# RUN: not llvm-objcopy --set-section-alignment=.foo=bar %t /dev/null 2>&1 | \ | ||
# RUN: FileCheck --check-prefix=INVALID-ALIGN %s | ||
# INVALID-ALIGN: error: invalid alignment for --set-section-alignment: 'bar' | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .foo | ||
Type: SHT_PROGBITS | ||
- Name: .bar | ||
Type: SHT_NOBITS | ||
- Name: .baz | ||
Type: SHT_NOTE | ||
AddressAlign: 4 |
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
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