Skip to content

Link error on Fedora 45, gcc 16.1.1: "relocation truncated to fit: R_X86_64_PC32 against rodata" and ".text" #414

Description

@DrDaveD

On Fedora 44 and rawhide (a.k.a 45) with x86_64 architecture and gcc 16.1.1, trying to compile proot v5.4.0 from source ends with the following errors:

  LD	loader/loader
loader/loader.o: in function `_start':
/proot/src/./loader/loader.c:131:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against `.rodata'
/proot/src/./loader/loader.c:218:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against `.rodata'
loader/loader.o:(.rodata+0x0): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x4): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x8): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0xc): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x10): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x14): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x18): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x1c): relocation truncated to fit: R_X86_64_PC32 against `.text'
loader/loader.o:(.rodata+0x20): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make: *** [GNUmakefile:273: loader/loader] Error 1
make: Leaving directory '/proot/src'

The easiest way to reproduce is to start a docker container on fedora:45 on an x86_64 host and do the following commands:

# dnf install -y gcc make libtalloc-devel git 
# git clone https://github.com/proot-me/proot.git
# cd proot
# git checkout v5.4.0
# make -C src proot

I have tried to figure out a solution but so far have only succeeded in getting rid of the .text section errors. That was done by editing GNUmakefile to add -mcmodel=large to LOADER_CFLAGS:

git diff src/GNUmakefile
diff --git a/src/GNUmakefile b/src/GNUmakefile
index 168a044..9d429d3 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -246,7 +246,7 @@ LOADER$1_OBJECTS = loader/loader$1.o loader/assembly$1.o
 $(eval $(call define_from_arch.h,$1,LOADER_ARCH_CFLAGS))
 $(eval $(call define_from_arch.h,$1,LOADER_ADDRESS))

-LOADER_CFLAGS$1  += -fPIC -ffreestanding $(LOADER_ARCH_CFLAGS$1)
+LOADER_CFLAGS$1  += -mcmodel=large -fPIC -ffreestanding $(LOADER_ARCH_CFLAGS$1)
 LOADER_LDFLAGS$1 += -static -nostdlib -Wl$(BUILD_ID_NONE),-Ttext=$(LOADER_ADDRESS$1),-z,noexecstack

 loader/loader$1.o: loader/loader.c

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions