Broken R_AVR_16 relocation? Or is my compiler wrong?
Dylan McKay <[email protected]> Thu, 7 Jan 2016 22:55:33 +1300
| Newsgroups | gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <CAHAccTM84a3SZnJOcjFhX5QGgT2c-uNp_5RqyqsLqh-sX2T=uQ@mail.gmail.com> |
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?
_______________________________________________
AVR-GCC-list mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list