Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
bbc752c5
Commit
bbc752c5
authored
Jun 08, 2019
by
Ben Gamari
🐢
Committed by
Marge Bot
Jun 12, 2019
Browse files
rts/linker: Make elf_got.c a bit more legible
parent
c05ca251
Changes
1
Hide whitespace changes
Inline
Side-by-side
rts/linker/elf_got.c
View file @
bbc752c5
...
...
@@ -52,11 +52,13 @@ makeGot(ObjectCode * oc) {
errorBelch
(
"MAP_FAILED. errno=%d"
,
errno
);
return
EXIT_FAILURE
;
}
oc
->
info
->
got_start
=
(
void
*
)
mem
;
/* update got_addr */
size_t
slot
=
0
;
for
(
ElfSymbolTable
*
symTab
=
oc
->
info
->
symbolTables
;
symTab
!=
NULL
;
symTab
=
symTab
->
next
)
symTab
!=
NULL
;
symTab
=
symTab
->
next
)
{
for
(
size_t
i
=
0
;
i
<
symTab
->
n_symbols
;
i
++
)
if
(
needGotSlot
(
symTab
->
symbols
[
i
].
elf_sym
))
symTab
->
symbols
[
i
].
got_addr
...
...
@@ -74,9 +76,12 @@ fillGot(ObjectCode * oc) {
/* fill the GOT table */
for
(
ElfSymbolTable
*
symTab
=
oc
->
info
->
symbolTables
;
symTab
!=
NULL
;
symTab
=
symTab
->
next
)
{
for
(
size_t
i
=
0
;
i
<
symTab
->
n_symbols
;
i
++
)
{
ElfSymbol
*
symbol
=
&
symTab
->
symbols
[
i
];
if
(
needGotSlot
(
symbol
->
elf_sym
))
{
/* no type are undefined symbols */
if
(
STT_NOTYPE
==
ELF_ST_TYPE
(
symbol
->
elf_sym
->
st_info
)
||
STB_WEAK
==
ELF_ST_BIND
(
symbol
->
elf_sym
->
st_info
))
{
...
...
@@ -93,22 +98,26 @@ fillGot(ObjectCode * oc) {
}
/* else it was defined somewhere in the same object, and
* we should have the address already.
*/
if
(
0x0
==
symbol
->
addr
)
{
errorBelch
(
"Something went wrong! Symbol %s has null address.
\n
"
,
symbol
->
name
);
return
EXIT_FAILURE
;
}
if
(
0x0
==
symbol
->
got_addr
)
{
errorBelch
(
"Not good either!"
);
return
EXIT_FAILURE
;
}
*
(
void
**
)
symbol
->
got_addr
=
symbol
->
addr
;
}
}
}
return
EXIT_SUCCESS
;
}
bool
verifyGot
(
ObjectCode
*
oc
)
{
for
(
ElfSymbolTable
*
symTab
=
oc
->
info
->
symbolTables
;
...
...
Ben Gamari
🐢
@bgamari
mentioned in commit
e628c7be
·
Jun 12, 2019
mentioned in commit
e628c7be
mentioned in commit e628c7be84ba59c947d51053599831c7df9a5492
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment