Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/test/ExecutionEngine/JITLink/AArch64/Inputs/x-0.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.section __DATA,__data
.globl x
.p2align 2, 0x0
x:
.long 0

.subsections_via_symbols
7 changes: 7 additions & 0 deletions llvm/test/ExecutionEngine/JITLink/AArch64/Inputs/x-1.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.section __DATA,__data
.globl x
.p2align 2, 0x0
x:
.long 1

.subsections_via_symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# RUN: rm -rf %t && mkdir -p %t
# RUN: llvm-mc -triple=arm64e-apple-darwin -filetype=obj -o %t/main.o %s
# RUN: llvm-mc -triple=arm64-apple-darwin -filetype=obj -o %t/x.arm64.o \
# RUN: %S/Inputs/x-1.s
# RUN: llvm-ar crs %t/libX.arm64.a %t/x.arm64.o
# RUN: llvm-mc -triple=arm64e-apple-darwin -filetype=obj -o %t/x.arm64e.o \
# RUN: %S/Inputs/x-0.s
# RUN: llvm-ar crs %t/libX.arm64e.a %t/x.arm64e.o
# RUN: llvm-lipo --create --output %t/libX.a %t/libX.arm64.a %t/libX.arm64e.a
# RUN: llvm-jitlink -noexec -check=%s %t/main.o -L%t -lX
#
# Create a universal archive with two slices (arm64e, arm64) each containing
# a definition of X: in arm64e X = 0, in arm64 X = 1.
# Check that if we load an arm64e object file then we link the arm64e slice
# of the archive by verifying that X = 0.
#

# jitlink-check: *{4}x = 0

.section __TEXT,__text,regular,pure_instructions
.globl _main
.p2align 2
_main:
mov w0, #0
ret

.section __DATA,__data
.globl p
p:
.quad x

.subsections_via_symbols
6 changes: 5 additions & 1 deletion llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,11 @@ static std::pair<Triple, SubtargetFeatures> getFirstFileTripleAndFeatures() {
case file_magic::macho_object: {
auto Obj = ExitOnErr(
object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef()));
Triple TT = Obj->makeTriple();
Triple TT;
if (auto *MachOObj = dyn_cast<object::MachOObjectFile>(Obj.get()))
TT = MachOObj->getArchTriple();
else
TT = Obj->makeTriple();
if (Magic == file_magic::coff_object) {
// TODO: Move this to makeTriple() if possible.
TT.setObjectFormat(Triple::COFF);
Expand Down