1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 13:06:59 +03:00

[ARM32] Show "recompile with -fPIC" error for absolute relocations

Fixes https://github.com/rui314/mold/issues/1220
This commit is contained in:
Rui Ueyama 2024-03-19 12:27:38 +09:00
parent e7dc90dadc
commit dda521e2bc
2 changed files with 20 additions and 2 deletions

View File

@ -606,6 +606,10 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_ARM_TARGET1:
scan_dyn_absrel(ctx, sym, rel);
break;
case R_ARM_MOVW_ABS_NC:
case R_ARM_THM_MOVW_ABS_NC:
scan_absrel(ctx, sym, rel);
break;
case R_ARM_THM_CALL:
case R_ARM_CALL:
case R_ARM_JUMP24:
@ -646,9 +650,7 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
case R_ARM_THM_JUMP11:
case R_ARM_THM_JUMP19:
case R_ARM_MOVW_PREL_NC:
case R_ARM_MOVW_ABS_NC:
case R_ARM_THM_MOVW_PREL_NC:
case R_ARM_THM_MOVW_ABS_NC:
case R_ARM_TLS_LDO32:
case R_ARM_V4BX:
case R_ARM_TLS_GOTDESC:

16
test/elf/arm_abs-error.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
. $(dirname $0)/common.inc
cat <<EOF | $CC -fPIC -c -o $t/a.o -xassembler - -mthumb
.globl foo
foo = 3;
EOF
cat <<EOF | $CC -fno-PIC -c -o $t/b.o -xc - -mthumb
#include <stdio.h>
extern char foo;
int main() { printf("foo=%p\n", &foo); }
EOF
! $CC -B. -o $t/exe -pie $t/a.o $t/b.o >& $t/log
grep -q 'recompile with -fPIC' $t/log