2019-10-02 20:41:25 +08:00
|
|
|
# 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
|
[yaml2obj, obj2yaml] - Add support for SHT_NOTE sections.
SHT_NOTE is the section that consists of
namesz, descsz, type, name + padding, desc + padding data.
This patch teaches yaml2obj, obj2yaml to dump and parse them.
This patch implements the section how it is described here:
https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html
Which says: "For 64–bit objects and 32–bit objects, each entry is an array of 4-byte words in
the format of the target processor"
The official specification is different
http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section
And says: "n 64-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS64), each entry is an array
of 8-byte words in the format of the target processor. In 32-bit objects (files with e_ident[EI_CLASS]
equal to ELFCLASS32), each entry is an array of 4-byte words in the format of the target processor"
Since LLVM uses the first, 32-bit way, this patch follows it.
Differential revision: https://reviews.llvm.org/D68983
2019-10-25 18:03:19 +08:00
|
|
|
Notes: []
|