bebbo / amiga-gcc

The GNU C-Compiler with Binutils and other useful tools for cross development for Amiga
GNU General Public License v2.0
319 stars 66 forks source link

relocation truncated to fit: DREL16 against `.bss' #309

Closed reinauer closed 1 year ago

reinauer commented 2 years ago

Still working on gathering a minimal case, but basically I have been changing my device driver to not have anything in the data segment.

Compiling with -fbaserel -msmall-code the driver compiles fine as long as there is still some data around, but as soon as no files has anything in the data segment (everything is in code and bss), compilation of the driver fails with:

Building a4091.device
objs/device.o: in function `init_device':
objs/device.o:(.text+0x54): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0xf0): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0xfc): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0x122): relocation truncated to fit: DREL16 against `.bss'
objs/device.o: in function `drv_expunge':
objs/device.o:(.text+0x180): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0x198): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0x1c6): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0x1f2): relocation truncated to fit: DREL16 against `.bss'
objs/device.o: in function `drv_open':
objs/device.o:(.text+0x224): relocation truncated to fit: DREL16 against `.bss'
objs/device.o:(.text+0x254): relocation truncated to fit: DREL16 against `.bss'
objs/device.o: in function `drv_close':
objs/device.o:(.text+0x26a): additional relocation overflows omitted from the output

My current workaround is to place the following in the code

int fake_data[1] = {1};

but that seems like a bad solution.

bebbo commented 2 years ago

well, you can use a short to waste only 2 bytes^^

bebbo commented 1 year ago

with the changed linker script, now a zero long word in the .data segment should always exist.