[lld-macho] Have toString() emit full path to archive files

It doesn't make sense to take just the base filename for archives when we emit
the full path for object files. (LLD-ELF emits the full path too.)

This will also make it easier to write a proper test for {D100147}.

Reviewed By: #lld-macho, oontvoo

Differential Revision: https://reviews.llvm.org/D100357
This commit is contained in:
Jez Ng 2021-04-13 10:40:22 -04:00
parent 35a745d814
commit 3142fc3b5b
4 changed files with 29 additions and 31 deletions

View File

@ -88,9 +88,7 @@ std::string lld::toString(const InputFile *f) {
if (f->archiveName.empty())
return std::string(f->getName());
return (path::filename(f->archiveName) + "(" + path::filename(f->getName()) +
")")
.str();
return (f->archiveName + "(" + path::filename(f->getName()) + ")").str();
}
SetVector<InputFile *> macho::inputFiles;

View File

@ -7,9 +7,9 @@
# RUN: not %lld -o /dev/null %t/main.o 2>&1 | \
# RUN: FileCheck %s -DSYM=_foo -DFILENAME=%t/main.o
# RUN: not %lld -o /dev/null %t/main.o %t/foo.a 2>&1 | \
# RUN: FileCheck %s -DSYM=_bar -DFILENAME='foo.a(foo.o)'
# RUN: FileCheck %s -DSYM=_bar -DFILENAME='%t/foo.a(foo.o)'
# RUN: not %lld -o /dev/null %t/main.o -force_load %t/foo.a 2>&1 | \
# RUN: FileCheck %s -DSYM=_bar -DFILENAME='foo.a(foo.o)'
# RUN: FileCheck %s -DSYM=_bar -DFILENAME='%t/foo.a(foo.o)'
# CHECK: error: undefined symbol: [[SYM]]
# CHECK-NEXT: >>> referenced by [[FILENAME]]

View File

@ -16,8 +16,8 @@
# RUN: not %lld %t/main.o %t/lib.a -u _asdf -o /dev/null 2>&1 | \
# RUN: FileCheck %s --check-prefix=UNDEF
# NOFOO-NOT: _foo forced load of lib.a(foo.o)
# FOO: _foo forced load of lib.a(foo.o)
# NOFOO-NOT: _foo forced load of {{.+}}lib.a(foo.o)
# FOO: _foo forced load of {{.+}}lib.a(foo.o)
# UNDEF: error: undefined symbol: _asdf
#--- foo.s

View File

@ -28,37 +28,37 @@
# RUN: %lld %t/main.o -force_load %t/lib.a -o /dev/null -ObjC -all_load -why_load | \
# RUN: FileCheck %s --check-prefix=WHYOBJCALLFORCE
# WHY-DAG: _bar forced load of lib.a(bar.o)
# WHY-DAG: __Z3foo forced load of lib.a(foo.o)
# WHY-NOT: {{.*}} forced load of lib.a(objc.o)
# WHY-DAG: _bar forced load of {{.+}}lib.a(bar.o)
# WHY-DAG: __Z3foo forced load of {{.+}}lib.a(foo.o)
# WHY-NOT: {{.+}} forced load of {{.+}}lib.a(objc.o)
# WHYFORCE-DAG: -force_load forced load of lib.a(bar.o)
# WHYFORCE-DAG: -force_load forced load of lib.a(foo.o)
# WHYFORCE-DAG: -force_load forced load of lib.a(objc.o)
# WHYFORCE-DAG: -force_load forced load of {{.+}}lib.a(bar.o)
# WHYFORCE-DAG: -force_load forced load of {{.+}}lib.a(foo.o)
# WHYFORCE-DAG: -force_load forced load of {{.+}}lib.a(objc.o)
# WHYALL-DAG: -all_load forced load of lib.a(bar.o)
# WHYALL-DAG: -all_load forced load of lib.a(foo.o)
# WHYALL-DAG: -all_load forced load of lib.a(objc.o)
# WHYALL-DAG: -all_load forced load of {{.+}}lib.a(bar.o)
# WHYALL-DAG: -all_load forced load of {{.+}}lib.a(foo.o)
# WHYALL-DAG: -all_load forced load of {{.+}}lib.a(objc.o)
# WHYALLFORCE-DAG: -force_load forced load of lib.a(bar.o)
# WHYALLFORCE-DAG: -force_load forced load of lib.a(foo.o)
# WHYALLFORCE-DAG: -force_load forced load of lib.a(objc.o)
# WHYALLFORCE-DAG: -force_load forced load of {{.+}}lib.a(bar.o)
# WHYALLFORCE-DAG: -force_load forced load of {{.+}}lib.a(foo.o)
# WHYALLFORCE-DAG: -force_load forced load of {{.+}}lib.a(objc.o)
# WHYOBJC-DAG: _bar forced load of lib.a(bar.o)
# WHYOBJC-DAG: __Z3foo forced load of lib.a(foo.o)
# WHYOBJC-DAG: -ObjC forced load of lib.a(objc.o)
# WHYOBJC-DAG: _bar forced load of {{.+}}lib.a(bar.o)
# WHYOBJC-DAG: __Z3foo forced load of {{.+}}lib.a(foo.o)
# WHYOBJC-DAG: -ObjC forced load of {{.+}}lib.a(objc.o)
# WHYOBJCFORCE-DAG: -force_load forced load of lib.a(bar.o)
# WHYOBJCFORCE-DAG: -force_load forced load of lib.a(foo.o)
# WHYOBJCFORCE-DAG: -force_load forced load of lib.a(objc.o)
# WHYOBJCFORCE-DAG: -force_load forced load of {{.+}}lib.a(bar.o)
# WHYOBJCFORCE-DAG: -force_load forced load of {{.+}}lib.a(foo.o)
# WHYOBJCFORCE-DAG: -force_load forced load of {{.+}}lib.a(objc.o)
# WHYOBJCALL-DAG: -all_load forced load of lib.a(bar.o)
# WHYOBJCALL-DAG: -all_load forced load of lib.a(foo.o)
# WHYOBJCALL-DAG: -all_load forced load of lib.a(objc.o)
# WHYOBJCALL-DAG: -all_load forced load of {{.+}}lib.a(bar.o)
# WHYOBJCALL-DAG: -all_load forced load of {{.+}}lib.a(foo.o)
# WHYOBJCALL-DAG: -all_load forced load of {{.+}}lib.a(objc.o)
# WHYOBJCALLFORCE-DAG: -force_load forced load of lib.a(bar.o)
# WHYOBJCALLFORCE-DAG: -force_load forced load of lib.a(foo.o)
# WHYOBJCALLFORCE-DAG: -force_load forced load of lib.a(objc.o)
# WHYOBJCALLFORCE-DAG: -force_load forced load of {{.+}}lib.a(bar.o)
# WHYOBJCALLFORCE-DAG: -force_load forced load of {{.+}}lib.a(foo.o)
# WHYOBJCALLFORCE-DAG: -force_load forced load of {{.+}}lib.a(objc.o)
#--- objc.s
.section __DATA,__objc_catlist