Linking addresses and -mcog
Circuitsoft
Posts: 1,166
I'm trying to convert Lonesock's FastFullDuplexSerial object to C, and running into issues.
All my experience with linking and symbols has been on processors with only one address space, so I'm not sure how to do this on PropGCC.
I'm sure that all these problems need the same fix, but I just don't know what it is.
All my experience with linking and symbols has been on processors with only one address space, so I'm not sure how to do this on PropGCC.
alex@alex-thinks ~/Projects/Parallax Library/serial $ cat Makefile CC=/opt/parallax/bin/propeller-elf-gcc CFLAGS=-g3 -DTEST all: ffds1 ffds1m.o: ffds1m.S $(CC) -c -o $@ -mcog $^ -g3 ffds1: ffds1.o ffds1m.o $(CC) -o $@ $^ alex@alex-thinks ~/Projects/Parallax Library/serial $ make -j2 /opt/parallax/bin/propeller-elf-gcc -g3 -DTEST -c -o ffds1.o ffds1.c /opt/parallax/bin/propeller-elf-gcc -c -o ffds1m.o -mcog ffds1m.S -g3 /opt/parallax/bin/propeller-elf-gcc -o ffds1 ffds1.o ffds1m.o ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x4): relocation truncated to fit: R_PROPELLER_SRC against symbol `ffds1.ctra_val' defined in .ffds1.text section in ffds1m.o ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x8): relocation truncated to fit: R_PROPELLER_SRC against symbol `ffds1.maskTX' defined in .ffds1.text section in ffds1m.o ffds1m.o: In function `ffds1.entry': (.ffds1.text+0xc): relocation truncated to fit: R_PROPELLER_SRC against symbol `ffds1.ctrb_val' defined in .ffds1.text section in ffds1m.o ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x14): relocation truncated to fit: R_PROPELLER_DST against `step_clocks' ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x14): relocation truncated to fit: R_PROPELLER_SRC against symbol `ffds1.period_ptr' defined in .ffds1.text section in ffds1m.o ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x1c): relocation truncated to fit: R_PROPELLER_DST against `timestamp' ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x1c): relocation truncated to fit: R_PROPELLER_SRC against `step_clocks' ffds1m.o: In function `ffds1.entry': (.ffds1.text+0x20): relocation truncated to fit: R_PROPELLER_DST against `timestamp' ffds1m.o: In function `rx_main': (.ffds1.text+0x28): relocation truncated to fit: R_PROPELLER_DST against `lockstep_ret' ffds1m.o: In function `rx_main': (.ffds1.text+0x28): relocation truncated to fit: R_PROPELLER_SRC against `tx_jump' ffds1m.o: In function `rx_main': (.ffds1.text+0x2c): additional relocation overflows omitted from the output collect2: ld returned 1 exit status make: *** [ffds1] Error 1
I'm sure that all these problems need the same fix, but I just don't know what it is.
Comments
.cog_ram Marks symbols to indicate that their values should be treated as long word
addresses, not byte addresses, by the linker. This is intended to duplicate the
standard behavior of the PASM assembler.
https://propgcc.googlecode.com/files/as.pdf page 211
Actually, I think it means you don't need to multiply their addresses. Eric or David may have better explanations - i'm not much of a gas user.
That's pretty much correct: .cog_ram makes the symbols long addresses rather than byte addresses, so if you want to refer to them in C functions (which typically expect byte addresses) you will have to multiply by 4. You could equally well modify the original assembly to use byte addresses instead; that's what spin2cpp --gas will do.
Eric