Skip to content

Commit ab90d7e

Browse files
committed
local symbols that need GOT slot require dynamic relocation
got slots requested for local symbols need dynamic relocation if building non static images Closes #101 Change-Id: I3b4c541e3e5af7184335420b5066c06c99873d70 Signed-off-by: Shankar Easwaran <[email protected]>
1 parent a02a875 commit ab90d7e

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

lib/Target/RISCV/RISCVRelocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ void RISCVRelocator::scanLocalReloc(InputFile &pInput, Relocation &pReloc,
432432
return;
433433
// If the GOT is used in statically linked binaries,
434434
// the GOT entry is enough and no relocation is needed.
435-
CreateGOT(Obj, pReloc, false, m_Target,
435+
CreateGOT(Obj, pReloc, !config().isCodeStatic(), m_Target,
436436
(config().codeGenType() == LinkerConfig::Exec));
437437
rsym->setReserved(rsym->reserved() | ReserveGOT);
438438
return;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.global _start
2+
3+
.type _start, %function
4+
_start:
5+
la t0, data
6+
ret
7+
data:
8+
.word 100
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#---LocalSymbolGOT.test--------------------- SharedLibrary------------------#
2+
#BEGIN_COMMENT
3+
#got slots requested for local symbols need dynamic relocation if building
4+
#non static images
5+
#----------------------------------------------------------------------------
6+
#END_COMMENT
7+
RUN: %clang %clangopts -fPIC -c %p/Inputs/got.s -o %t1.got.o
8+
RUN: %link %linkopts -shared %t1.got.o -o %t1.so
9+
RUN: %readelf -r %t1.so | %filecheck %s -check-prefix=DYNREL
10+
11+
#DYNREL: R_RISCV_RELATIVE

0 commit comments

Comments
 (0)