[dsymutil] Generalize handling of aliases external symbols

In f9fb9da36c we fixed spurious warnings
caused by aliases to private extern symbols. This patch generalizes that
to regular external symbols as well.
This commit is contained in:
Jonas Devlieghere 2020-11-16 11:02:40 -08:00
parent 0b6090699a
commit ee91e2311c
5 changed files with 14 additions and 3 deletions

View File

@ -10,6 +10,18 @@ int* bar() {
return foo();
}
$ cat extern.c
__attribute__((visibility("hidden")))
int* foo() {
int i = 10;
volatile int* j = &i;
return j;
}
int* bar() {
return foo();
}
$ cat main.c
int* bar();
int main() {
@ -24,6 +36,7 @@ $ xcrun --sdk iphoneos clang -g main.c -c -o main.o -target arm64-apple-ios14.0
$ xcrun --sdk iphoneos clang private_extern.o main.o -target arm64-apple-ios14.0 -o private_extern.out -Xlinker -alias_list -Xlinker alias_list
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/private_extern/private_extern.out -o %t.dSYM --verbose 2>&1 | FileCheck %s
RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/extern/extern.out -o %t.dSYM --verbose 2>&1 | FileCheck %s
CHECK-NOT: could not find object file symbol for symbol _baz
CHECK: { sym: _foo, objAddr: 0x0000000000000000, binAddr: 0x0000000100007F58, size: 0x00000020 }
CHECK: { sym: _baz, objAddr: 0x0000000000000000, binAddr: 0x0000000100007F58, size: 0x00000000 }

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -562,9 +562,7 @@ void MachODebugMapParser::loadMainBinarySymbols(
continue;
}
Section = *SectionOrErr;
if ((Section == MainBinary.section_end() || Section->isText()) &&
!(SymType &
MachO::N_PEXT)) // Alias to non-external (was a private external)
if ((Section == MainBinary.section_end() || Section->isText()) && !Extern)
continue;
uint64_t Addr = cantFail(Sym.getValue());
Expected<StringRef> NameOrErr = Sym.getName();