blob: 6688d9c9ba386192476d9b76e7068950c12d9bde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 2000-2015
*
* RTS Symbols
*
* ---------------------------------------------------------------------------*/
#include "ghcplatform.h"
#include "RtsSymbolInfo.h"
#include "Rts.h"
#include "HsFFI.h"
#include "Hash.h"
#include "RtsUtils.h"
typedef struct _SymbolInfo {
/* Determines if the
symbol is weak */
HsBool isWeak;
} SymbolInfo;
/* -----------------------------------------------------------------------------
* Performs a check to see if the symbol at the given address
* is a weak symbol or not.
*
* Returns: HS_BOOL_TRUE on symbol being weak, else HS_BOOL_FALSE
*/
HsBool isSymbolWeak(ObjectCode *owner, void *label)
{
SymbolInfo *info;
if (owner
&& label
&& owner->extraInfos
&& (info = lookupStrHashTable(owner->extraInfos, label)) != NULL)
{
return info->isWeak;
}
return HS_BOOL_FALSE;
}
/* -----------------------------------------------------------------------------
* Marks the symbol at the given address as weak or not.
* If the extra symbol infos table has not been initialized
* yet this will create and allocate a new Hashtable
*/
void setWeakSymbol(ObjectCode *owner, void *label)
{
SymbolInfo *info;
if (owner && label)
{
info = NULL;
if (!owner->extraInfos)
{
owner->extraInfos = allocStrHashTable();
}
else {
info = lookupStrHashTable(owner->extraInfos, label);
}
if (!info){
info = stgMallocBytes(sizeof(SymbolInfo), "setWeakSymbol");
}
info->isWeak = HS_BOOL_TRUE;
insertStrHashTable(owner->extraInfos, label, info);
}
}
|