1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[JITLink][MachO] Use correct symbol scope when N_PEXT is set and N_EXT unset.

MachOLinkGraphBuilder has been treating these as hidden, but they should be
treated as local.

Symbols with N_PEXT set and N_EXT unset are produced when hidden symbols are
run through 'ld -r' without passing -keep_private_externs. They will show up
under 'nm -m' as "was private extern", hence the name of the test cases.

Testcase commited as relocatable object to ensure that the test suite doesn't
depend on having 'ld -r' available.
This commit is contained in:
Lang Hames 2020-08-15 15:45:49 -07:00
parent 23bcf50ec2
commit 90bd74632c
3 changed files with 10 additions and 3 deletions

View File

@ -64,10 +64,8 @@ Linkage MachOLinkGraphBuilder::getLinkage(uint16_t Desc) {
}
Scope MachOLinkGraphBuilder::getScope(StringRef Name, uint8_t Type) {
if (Type & MachO::N_PEXT)
return Scope::Hidden;
if (Type & MachO::N_EXT) {
if (Name.startswith("l"))
if ((Type & MachO::N_PEXT) || Name.startswith("l"))
return Scope::Hidden;
else
return Scope::Default;

View File

@ -0,0 +1,9 @@
# RUN: llvm-jitlink -noexec %S/Inputs/MachO_x86-64_was_private_extern.o
#
# Perform a no-exec link of MachO_x86-64_was_private_extern.o and verify that
# it does not generate any errors despite the presence of a 'was private
# extern' symbol (N_PEXT set, N_EXT unset).
#
# The test case for this is a relocatable object file rather than assembly as
# objects must be run through ld64's 'ld -r' mode to produce them and we can't
# assume that that is available everywhere.