|
From: | Dylan McKay |
Subject: | [avr-gcc-list] Broken R_AVR_16 relocation? Or is my compiler wrong? |
Date: | Thu, 7 Jan 2016 22:55:33 +1300 |
Hello there,
I am generating AVR executables with my own compiler, but linking them with AVR-GCC
.
Here is an example of a C file, which avr-as
compiles fine. I made sure to first use my compiler to generate assembly from this file, and then assemble this using my compiler and gcc
so that they are both using the same assembly source file.
void foo();
int bar = 2;
int abc = 2;
int jmp __attribute__((section(".vectors"))) = 0x940C;
void (*ptr)() __attribute__((section(".vectors"))) = (&foo);
void milan() { }
void foo(){}
void inter() { }
int qwerty = 2;
The .vectors
section is generated fine. The correct jmp
instruction is placed. Both compilers generate R_AVR_16
relocations for this.
GCC however generates this (avr-objdump
output):
RELOCATION RECORDS FOR [.vectors]:
OFFSET TYPE VALUE
00000004 R_AVR_16 .text+0x00000004
Note that .text+0x00000004
does point to foo
in the object file.
Whereas my compiler generates this:
RELOCATION RECORDS FOR [.vectors]:
OFFSET TYPE VALUE
00000002 R_AVR_16 foo
The problem is that GCC’s hardcoded section+offset
works, but my symbol
does not. avr-ld
correctly relocates GCC code to foo
in the executable, but relocates my code to _etext+0x2
.
Am I doing something wrong, or is not just not properly supported?
[Prev in Thread] | Current Thread | [Next in Thread] |