-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lld-macho] Support archives without index #132942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; REQUIRES: x86 | ||
; RUN: rm -rf %t; split-file %s %t | ||
|
||
; RUN: llvm-as %t/lib.ll -o %t/lib.o | ||
; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s | ||
; RUN: llvm-ar rcST %t/lib.a %t/lib.o | ||
; RUN: %lld %t/main.o %t/lib.a -o %t/out | ||
|
||
;--- main.s | ||
.global _main | ||
_main: | ||
call _foo | ||
mov $0, %rax | ||
ret | ||
|
||
;--- lib.ll | ||
target triple = "x86_64-apple-darwin" | ||
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() { | ||
entry: | ||
ret void | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# REQUIRES: x86 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get a bitcode test too, since this adds support for that as well as far as I can tell? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
# RUN: rm -rf %t; split-file %s %t | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/lib.o %t/lib.s | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/lib2.o %t/lib2.s | ||
# RUN: llvm-ar crST %t/lib.a %t/lib.o %t/lib2.o | ||
# RUN: %lld %t/main.o %t/lib.a -o %t/out | ||
# RUN: llvm-nm %t/out | FileCheck %s | ||
|
||
# CHECK-NOT: T _bar | ||
# CHECK: T _foo | ||
|
||
## Test that every kind of eager load mechanism still works. | ||
# RUN: %lld %t/main.o %t/lib.a -all_load -o %t/all_load | ||
# RUN: llvm-nm %t/all_load | FileCheck %s --check-prefix FORCED-LOAD | ||
# RUN: %lld %t/main.o -force_load %t/lib.a -o %t/force_load | ||
# RUN: llvm-nm %t/force_load | FileCheck %s --check-prefix FORCED-LOAD | ||
# RUN: %lld %t/main.o %t/lib.a -ObjC -o %t/objc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re -ObjC: How expensive would it be to look at objc symbols in all LazyObjects? (But fine to punt on this for now: As you say, it's not clear if it's needed, and the current behavior is consistent with -start-lib / -end-lib.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relatively cheap if we do it |
||
# RUN: llvm-nm %t/objc | FileCheck %s --check-prefix FORCED-LOAD | ||
|
||
# FORCED-LOAD: T _bar | ||
|
||
#--- lib.s | ||
.global _foo | ||
_foo: | ||
ret | ||
|
||
#--- lib2.s | ||
.section __DATA,__objc_catlist | ||
.quad 0x1234 | ||
|
||
.section __TEXT,__text | ||
.global _bar | ||
_bar: | ||
ret | ||
|
||
#--- main.s | ||
.global _main | ||
_main: | ||
call _foo | ||
mov $0, %rax | ||
ret |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for when we first read a .a but it's then
-all_load
/-force_load
ed later, yes?Do we parse all .o files a second time then? (In any case, this isn't something that we expect to happen in practice, yes?)
(ps: good tests for this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going off the logic in Driver.cpp, specifically:
so I guess it's your scenario but s/force_load/LC_LINKER_OPTION. I think we would actually drop the force load in that case. Is that a bug?