Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld-macho] Support parsing of bitcode within archives
Also error out if we find anything other than an object or bitcode file in the archive. Note that we were previously inserting the symbols and sections of the unpacked ObjFile into the containing ArchiveFile. This was actually unnecessary -- we can just insert the ObjectFile (or BitcodeFile) into the `inputFiles` vector. This is the approach taken by LLD-ELF. Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D92539
- Loading branch information
Showing
4 changed files
with
77 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
; REQUIRES: x86 | ||
; RUN: llvm-as %s -o %t.o | ||
; RUN: not %lld %t.o -o /dev/null 2>&1 | FileCheck %s | ||
|
||
; CHECK: error: input module has no datalayout | ||
|
||
; This bitcode file has no datalayout. | ||
; Check that we error out producing a reasonable diagnostic. | ||
target triple = "x86_64-apple-macosx10.15.0" | ||
|
||
define void @_start() { | ||
ret void | ||
} |
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,20 @@ | ||
# REQUIRES: x86 | ||
# RUN: split-file %s %t | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o | ||
# RUN: %lld -dylib -lSystem %t/foo.o -o %t/foo.dylib | ||
# RUN: rm -f %t/foo.a | ||
# RUN: llvm-ar rcs %t/foo.a %t/foo.dylib | ||
# RUN: not %lld %t/test.o %t/foo.a -o /dev/null 2>&1 | FileCheck %s -DFILE=%t/foo.a | ||
# CHECK: error: [[FILE]]: archive member foo.dylib has unhandled file type | ||
|
||
#--- foo.s | ||
.globl _foo | ||
_foo: | ||
ret | ||
|
||
#--- test.s | ||
.globl _main | ||
_main: | ||
callq _foo | ||
ret |
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,28 @@ | ||
; REQUIRES: x86 | ||
; RUN: split-file %s %t | ||
; RUN: llvm-as %t/foo.ll -o %t/foo.o | ||
; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o | ||
; RUN: rm -f %t/foo.a | ||
; RUN: llvm-ar rcs %t/foo.a %t/foo.o | ||
; RUN: %lld -save-temps -lSystem %t/test.o %t/foo.a -o %t/test | ||
; RUN: llvm-objdump -d --macho --no-show-raw-insn %t/test | FileCheck %s | ||
|
||
; CHECK: _main: | ||
; CHECK-NEXT: callq _foo | ||
; CHECK-NEXT: retq | ||
|
||
;--- foo.ll | ||
|
||
target triple = "x86_64-apple-macosx10.15.0" | ||
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
define void @foo() { | ||
ret void | ||
} | ||
|
||
;--- test.s | ||
|
||
.globl _main | ||
_main: | ||
callq _foo | ||
ret |