summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-04-21 11:44:07 +0800
committerMoritz Angermann <moritz.angermann@gmail.com>2020-04-21 11:44:07 +0800
commitae94af3e0d5cdc2b16b7f550260ee9b3964a3fda (patch)
tree00dbc565a7a03be4decbfc71f831b8b241916ee4
parentd5fae7da02cff1c7ec7b8e472f85d23aef098968 (diff)
downloadhaskell-wip/angerman/fix-macos-linker.tar.gz
Fix build warning; add more informative information to the linker; fix linker for empty sectionswip/angerman/fix-macos-linker
-rw-r--r--rts/linker/MachO.c19
-rw-r--r--rts/posix/GetTime.c1
2 files changed, 15 insertions, 5 deletions
diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c
index 6e379ffb53..58712075b2 100644
--- a/rts/linker/MachO.c
+++ b/rts/linker/MachO.c
@@ -677,6 +677,14 @@ static int
relocateSection(ObjectCode* oc, int curSection)
{
Section * sect = &oc->sections[curSection];
+
+ IF_DEBUG(linker, debugBelch("relocateSection %d, info: %x\n", curSection, sect->info));
+
+ // empty sections (without segments), won't have their info filled.
+ // there is no relocation to be done for them.
+ if(sect->info == NULL)
+ return 1;
+
MachOSection * msect = sect->info->macho_section; // for access convenience
MachORelocationInfo * relocs = sect->info->relocation_info;
MachOSymbol * symbols = oc->info->macho_symbols;
@@ -1192,7 +1200,7 @@ ocGetNames_MachO(ObjectCode* oc)
SymbolAddr* commonStorage = NULL;
unsigned long commonCounter;
- IF_DEBUG(linker,debugBelch("ocGetNames_MachO: start\n"));
+ IF_DEBUG(linker,debugBelch("ocGetNames_MachO: %s start\n", OC_INFORMATIVE_FILENAME(oc)));
Section *secArray;
secArray = (Section*)stgCallocBytes(
@@ -1449,7 +1457,7 @@ ocMprotect_MachO( ObjectCode *oc )
int
ocResolve_MachO(ObjectCode* oc)
{
- IF_DEBUG(linker, debugBelch("ocResolve_MachO: start\n"));
+ IF_DEBUG(linker, debugBelch("ocResolve_MachO: %s start\n", OC_INFORMATIVE_FILENAME(oc)));
if(NULL != oc->info->dsymCmd)
{
@@ -1460,6 +1468,9 @@ ocResolve_MachO(ObjectCode* oc)
for (int i = 0; i < oc->n_sections; i++)
{
const char * sectionName = oc->info->macho_sections[i].sectname;
+
+ IF_DEBUG(linker, debugBelch("ocResolve_MachO: section %d/%d: %s\n", i, oc->n_sections, sectionName));
+
if( !strcmp(sectionName,"__la_symbol_ptr")
|| !strcmp(sectionName,"__la_sym_ptr2")
|| !strcmp(sectionName,"__la_sym_ptr3"))
@@ -1483,7 +1494,7 @@ ocResolve_MachO(ObjectCode* oc)
}
else
{
- IF_DEBUG(linker, debugBelch("ocResolve_MachO: unknown section\n"));
+ IF_DEBUG(linker, debugBelch("ocResolve_MachO: unknown section %d/%d\n", i, oc->n_sections));
}
}
}
@@ -1520,7 +1531,7 @@ ocResolve_MachO(ObjectCode* oc)
for(int i = 0; i < oc->n_sections; i++)
{
- IF_DEBUG(linker, debugBelch("ocResolve_MachO: relocating section %d\n", i));
+ IF_DEBUG(linker, debugBelch("ocResolve_MachO: relocating section %d/%d\n", i, oc->n_sections));
#if defined(aarch64_HOST_ARCH)
if (!relocateSectionAarch64(oc, &oc->sections[i]))
diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c
index eda18e1202..602bd17b52 100644
--- a/rts/posix/GetTime.c
+++ b/rts/posix/GetTime.c
@@ -71,7 +71,6 @@ Time getCurrentThreadCPUTime(void)
// support clock_getcpuclockid. Hence we prefer to use the Darwin-specific
// path on Darwin, even if clock_gettime is available.
#if defined(darwin_HOST_OS)
- mach_port_t port = pthread_mach_thread_np(osThreadId());
thread_basic_info_data_t info = { 0 };
mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT;
kern_return_t kern_err = thread_info(mach_thread_self(), THREAD_BASIC_INFO,