forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
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 of symbol modification flags for MachO (ll…
…vm#120895) This patch adds support of the following llvm-objcopy flags for MachO: - `--globalize-symbol`, `--globalize-symbols`, - `--keep-global-symbol`, `-G`, `--keep-global-symbols`, - `--localize-symbol`, `-L`, `--localize-symbols`, - `--skip-symbol`, `--skip-symbols`. Code in `updateAndRemoveSymbols` for MachO is kept similar to its version for ELF. Fixes llvm#120894
- Loading branch information
Showing
10 changed files
with
659 additions
and
62 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
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
134 changes: 134 additions & 0 deletions
134
llvm/test/tools/llvm-objcopy/MachO/globalize-symbol.test
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,134 @@ | ||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objcopy --wildcard --globalize-symbol="*" %t %t.copy | ||
# RUN: llvm-readobj --symbols %t.copy | FileCheck %s | ||
|
||
# RUN: echo "*" > %t-star.txt | ||
# RUN: llvm-objcopy --wildcard --globalize-symbols="%t-star.txt" %t %t.copy | ||
# RUN: llvm-readobj --symbols %t.copy | FileCheck %s | ||
|
||
# CHECK: Symbols [ | ||
# CHECK-NEXT: Symbol { | ||
# CHECK-NEXT: Name: _PrivateSymbol | ||
# CHECK-NEXT: Extern | ||
# CHECK-NEXT: Type: Section (0xE) | ||
# CHECK-NEXT: Section: __text (0x1) | ||
# CHECK-NEXT: RefType: UndefinedNonLazy (0x0) | ||
# CHECK-NEXT: Flags [ (0x0) | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Value: 0x1 | ||
# CHECK-NEXT: } | ||
# CHECK-NEXT: Symbol { | ||
# CHECK-NEXT: Name: _PrivateExternalSymbol | ||
# CHECK-NEXT: PrivateExtern | ||
# CHECK-NEXT: Extern | ||
# CHECK-NEXT: Type: Section (0xE) | ||
# CHECK-NEXT: Section: __text (0x1) | ||
# CHECK-NEXT: RefType: UndefinedNonLazy (0x0) | ||
# CHECK-NEXT: Flags [ (0x0) | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Value: 0x2 | ||
# CHECK-NEXT: } | ||
# CHECK-NEXT: Symbol { | ||
# CHECK-NEXT: Name: _CommonSymbol | ||
# CHECK-NEXT: Extern | ||
# CHECK-NEXT: Type: Section (0xE) | ||
# CHECK-NEXT: Section: __text (0x1) | ||
# CHECK-NEXT: RefType: UndefinedNonLazy (0x0) | ||
# CHECK-NEXT: Flags [ (0x0) | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Value: 0x3 | ||
# CHECK-NEXT: } | ||
# CHECK-NEXT: Symbol { | ||
# CHECK-NEXT: Name: _UndefinedExternalSymbol | ||
# CHECK-NEXT: Extern | ||
# CHECK-NEXT: Type: Undef (0x0) | ||
# CHECK-NEXT: Section: (0x0) | ||
# CHECK-NEXT: RefType: UndefinedNonLazy (0x0) | ||
# CHECK-NEXT: Flags [ (0x0) | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Value: 0x0 | ||
# CHECK-NEXT: } | ||
# CHECK-NEXT: ] | ||
|
||
--- !mach-o | ||
FileHeader: | ||
magic: 0xFEEDFACF | ||
cputype: 0x100000C | ||
cpusubtype: 0x0 | ||
filetype: 0x2 | ||
ncmds: 3 | ||
sizeofcmds: 328 | ||
flags: 0x200085 | ||
reserved: 0x0 | ||
LoadCommands: | ||
- cmd: LC_SEGMENT_64 | ||
cmdsize: 152 | ||
segname: __TEXT | ||
vmaddr: 4294967296 | ||
vmsize: 4096 | ||
fileoff: 0 | ||
filesize: 4096 | ||
maxprot: 5 | ||
initprot: 5 | ||
nsects: 1 | ||
flags: 0 | ||
Sections: | ||
- sectname: __text | ||
segname: __TEXT | ||
addr: 0x100000FF8 | ||
size: 8 | ||
offset: 0xFF8 | ||
align: 2 | ||
reloff: 0x0 | ||
nreloc: 0 | ||
flags: 0x80000400 | ||
reserved1: 0x0 | ||
reserved2: 0x0 | ||
reserved3: 0x0 | ||
content: 00008052C0035FD6 | ||
- cmd: LC_SEGMENT_64 | ||
cmdsize: 72 | ||
segname: __LINKEDIT | ||
vmaddr: 4294971392 | ||
vmsize: 4096 | ||
fileoff: 4096 | ||
filesize: 67 | ||
maxprot: 1 | ||
initprot: 1 | ||
nsects: 0 | ||
flags: 0 | ||
- cmd: LC_SYMTAB | ||
cmdsize: 24 | ||
symoff: 4096 | ||
nsyms: 4 | ||
stroff: 4164 | ||
strsize: 79 | ||
LinkEditData: | ||
NameList: | ||
- n_strx: 2 | ||
n_type: 0x0E | ||
n_sect: 1 | ||
n_desc: 0 | ||
n_value: 1 | ||
- n_strx: 17 | ||
n_type: 0x1E | ||
n_sect: 1 | ||
n_desc: 0 | ||
n_value: 2 | ||
- n_strx: 40 | ||
n_type: 0x0F | ||
n_sect: 1 | ||
n_desc: 0 | ||
n_value: 3 | ||
- n_strx: 54 | ||
n_type: 0x01 | ||
n_sect: 0 | ||
n_desc: 0 | ||
n_value: 0 | ||
StringTable: | ||
- ' ' | ||
- _PrivateSymbol | ||
- _PrivateExternalSymbol | ||
- _CommonSymbol | ||
- _UndefinedExternalSymbol | ||
... |
Oops, something went wrong.