[commit: ghc] master, wip/deploy-docs, wip/packaging-fail, wip/run-nofib, wip/windows-32bit: Gracefully handle error condition in Mach-O relocateSection (3fb10fc)

git at git.haskell.org git at git.haskell.org
Thu Mar 21 17:00:59 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branches: master,wip/deploy-docs,wip/packaging-fail,wip/run-nofib,wip/windows-32bit
Link       : http://ghc.haskell.org/trac/ghc/changeset/3fb10fcfc03d5590579743494450fc8b06b179ad/ghc

>---------------------------------------------------------------

commit 3fb10fcfc03d5590579743494450fc8b06b179ad
Author: Artem Pyanykh <artempyanykh at gmail.com>
Date:   Sat Mar 16 18:32:00 2019 +0300

    Gracefully handle error condition in Mach-O relocateSection


>---------------------------------------------------------------

3fb10fcfc03d5590579743494450fc8b06b179ad
 rts/linker/MachO.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c
index 6e109e5..21e46a3 100644
--- a/rts/linker/MachO.c
+++ b/rts/linker/MachO.c
@@ -814,7 +814,11 @@ relocateSection(ObjectCode* oc, int curSection)
                     // symbol address (symbol->n_value)
 
                     if ((symbol->nlist->n_type & N_TYPE) == N_SECT) {
-                        ASSERT(symbol->addr != NULL);
+                        if (symbol->addr == NULL) {
+                            errorBelch("relocateSection: address of internal symbol %s was not resolved\n", nm);
+                            return 0;
+                        }
+
                         addr = symbol->addr;
 
                         IF_DEBUG(linker, debugBelch("relocateSection: calculated relocation of "
@@ -823,6 +827,7 @@ relocateSection(ObjectCode* oc, int curSection)
                     } else {
                         errorBelch("\nrelocateSection: %s is not exported,"
                                    " and should be defined in a section, but isn't!\n", nm);
+                        return 0;
                     }
             }
 



More information about the ghc-commits mailing list