Skip to content

Commit

Permalink
Fix mismatched visibility of assembler impls of StgRun
Browse files Browse the repository at this point in the history
Based on a patch from PHO, in trac #7813.

We were previously declaring StgRun as a private symbol (in
rts/StgRun.h), but were actually defining it as a public one (in
rts/StgCRun.c). This caused a linkage problem with old binutils. See:
http://www.haskell.org/pipermail/ghc-devs/2013-April/000932.html
  • Loading branch information
Ian Lynagh committed Apr 27, 2013
1 parent c47c47a commit f6e0dbf
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions rts/StgCRun.c
Expand Up @@ -118,8 +118,10 @@ StgWord8 *win32AllocStack(void)

#ifdef darwin_HOST_OS
#define STG_GLOBAL ".globl "
#define STG_HIDDEN ".private_extern "
#else
#define STG_GLOBAL ".global "
#define STG_HIDDEN ".hidden "
#endif

/*
Expand Down Expand Up @@ -164,6 +166,7 @@ StgRunIsImplementedInAssembler(void)
{
__asm__ volatile (
STG_GLOBAL STG_RUN "\n"
STG_HIDDEN STG_RUN "\n"
STG_RUN ":\n\t"
/*
Expand Down Expand Up @@ -236,7 +239,13 @@ StgRunIsImplementedInAssembler(void)

#ifdef x86_64_HOST_ARCH

extern StgRegTable * StgRun(StgFunPtr f, StgRegTable *basereg);
#define STG_GLOBAL ".globl "

#ifdef darwin_HOST_OS
#define STG_HIDDEN ".private_extern "
#else
#define STG_HIDDEN ".hidden "
#endif

static void GNUC3_ATTRIBUTE(used)
StgRunIsImplementedInAssembler(void)
Expand All @@ -245,7 +254,8 @@ StgRunIsImplementedInAssembler(void)
/*
* save callee-saves registers on behalf of the STG code.
*/
".globl " STG_RUN "\n"
STG_GLOBAL STG_RUN "\n"
STG_HIDDEN STG_RUN "\n"
STG_RUN ":\n\t"
"subq %1, %%rsp\n\t"
"movq %%rsp, %%rax\n\t"
Expand Down Expand Up @@ -400,19 +410,26 @@ StgRun(StgFunPtr f, StgRegTable *basereg) {

#ifdef powerpc_HOST_ARCH

extern StgRegTable * StgRun(StgFunPtr f, StgRegTable *basereg);
#define STG_GLOBAL ".globl "

#ifdef darwin_HOST_OS
#define STG_HIDDEN ".private_extern "
#else
#define STG_HIDDEN ".hidden "
#endif

#ifdef darwin_HOST_OS
void StgRunIsImplementedInAssembler(void)
{
#if HAVE_SUBSECTIONS_VIA_SYMBOLS
// if the toolchain supports deadstripping, we have to
// prevent it here (it tends to get confused here).
__asm__ volatile (".no_dead_strip _StgRunIsImplementedInAssembler");
__asm__ volatile (".no_dead_strip _StgRunIsImplementedInAssembler\n");
#endif
__asm__ volatile (
"\n.globl _StgRun\n"
"_StgRun:\n"
STG_GLOBAL STG_RUN "\n"
STG_HIDDEN STG_RUN "\n"
STG_RUN ":\n"
"\tmflr r0\n"
"\tbl saveFP # f14\n"
"\tstmw r13,-220(r1)\n"
Expand Down Expand Up @@ -446,6 +463,7 @@ StgRunIsImplementedInAssembler(void)
{
__asm__ volatile (
"\t.globl StgRun\n"
"\t.hidden StgRun\n"
"\t.type StgRun,@function\n"
"StgRun:\n"
"\tmflr 0\n"
Expand Down Expand Up @@ -518,8 +536,6 @@ StgRunIsImplementedInAssembler(void)
#ifdef powerpc64_HOST_ARCH

#ifdef linux_HOST_OS
extern StgRegTable * StgRun(StgFunPtr f, StgRegTable *basereg);

static void GNUC3_ATTRIBUTE(used)
StgRunIsImplementedInAssembler(void)
{
Expand All @@ -534,6 +550,7 @@ StgRunIsImplementedInAssembler(void)
".section \".opd\",\"aw\"\n"
".align 3\n"
".globl StgRun\n"
".hidden StgRun\n"
"StgRun:\n"
"\t.quad\t.StgRun,.TOC.@tocbase,0\n"
"\t.size StgRun,24\n"
Expand Down

0 comments on commit f6e0dbf

Please sign in to comment.