Commit 69d5ad06 authored by Moritz Angermann's avatar Moritz Angermann Committed by Ben Gamari

catch the case where there is no symCmd

We do check for symCmd, to set the info->nlist value, but forgot to do
the same check for info->names.  Thus when trying to extract stroff from
symCmd, we hit a segfault.

Test Plan: The validation failure on windows is rather suspicious...
let's try this one

Reviewers: bgamari, adinapoli, austin, erikd, simonmar

Reviewed By: adinapoli

Subscribers: thomie, rwbarton

Differential Revision:
parent cfff183f
......@@ -1215,6 +1215,8 @@ mkOc( pathchar *path, char *image, int imageSize,
IF_DEBUG(linker, debugBelch("mkOc: start\n"));
oc = stgMallocBytes(sizeof(ObjectCode), "mkOc(oc)");
oc->info = NULL;
# if defined(OBJFORMAT_ELF)
oc->formatName = "ELF";
# elif defined(OBJFORMAT_PEi386)
......@@ -130,7 +130,9 @@ ocInit_MachO(ObjectCode * oc)
oc->info->nlist = oc->info->symCmd == NULL
: (MachONList *)(oc->image + oc->info->symCmd->symoff);
oc->info->names = oc->image + oc->info->symCmd->stroff;
oc->info->names = oc->info->symCmd == NULL
: (oc->image + oc->info->symCmd->stroff);
/* If we have symbols, allocate and fill the macho_symbols
* This will make relocation easier.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment