--- /dev/null
+$ cat foo.c
+void start(void) asm("start");
+void start(void) {}
+$ xcrun clang -c -o foo.o foo.c -g3
+$ xcrun clang -o foo foo.o -g3 -Wl,-preload -nodefaultlibs
+
+RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/preload/foo -o %t.dSYM
+RUN: llvm-nm %p/../Inputs/private/tmp/preload/foo | FileCheck %s
+RUN: llvm-nm %t.dSYM/Contents/Resources/DWARF/foo | FileCheck %s
+CHECK: start
return Obj.getHeader().filetype != MachO::MH_OBJECT;
}
-static bool hasLinkEditSegment(const object::MachOObjectFile &Obj) {
- bool HasLinkEditSegment = false;
- iterateOnSegments(Obj, [&](const MachO::segment_command_64 &Segment) {
- if (StringRef("__LINKEDIT") == Segment.segname)
- HasLinkEditSegment = true;
- });
- return HasLinkEditSegment;
-}
-
static unsigned segmentLoadCommandSize(bool Is64Bit, unsigned NumSections) {
if (Is64Bit)
return sizeof(MachO::segment_command_64) +
unsigned LoadCommandSize = 0;
unsigned NumLoadCommands = 0;
- // Get LC_UUID and LC_BUILD_VERSION.
+ bool HasSymtab = false;
+
+ // Check LC_SYMTAB and get LC_UUID and LC_BUILD_VERSION.
MachO::uuid_command UUIDCmd;
SmallVector<MachO::build_version_command, 2> BuildVersionCmd;
memset(&UUIDCmd, 0, sizeof(UUIDCmd));
BuildVersionCmd.push_back(Cmd);
break;
}
+ case MachO::LC_SYMTAB:
+ HasSymtab = true;
+ break;
default:
break;
}
}
// If we have a valid symtab to copy, do it.
- bool ShouldEmitSymtab =
- isExecutable(InputBinary) && hasLinkEditSegment(InputBinary);
+ bool ShouldEmitSymtab = HasSymtab && isExecutable(InputBinary);
if (ShouldEmitSymtab) {
LoadCommandSize += sizeof(MachO::symtab_command);
++NumLoadCommands;