I am using objcopy to convert elf to hex. When I disassemble the elf in IDA Pro, all the sections are present, but they are missing from my hex and it seems the elf headers:
C:\TricoreGCC>tricore-readelf -l test1.elf
Elf file type is EXEC (Executable file)
Entry point 0x80132000
There are 3 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x80130000 0x80130000 0x023e8 0x023e8 R E 0x4000
LOAD 0x003000 0x801cb000 0x801cb000 0x01478 0x01478 RW 0x4000
LOAD 0x005500 0xd0015500 0xd0015500 0x00000 0x00008 RW 0x4000
Section to Segment mapping:
Segment Sections...
00 .text .rodata
01 .data
02 .bss
In an assembler file I have this:
.section .jfuel , "x"
j translatefuel
In a linker script file I have this:
SECTIONS
{
. = 0x800B5964;
.jfuel : { *(.jfuel) }
. = 0x80132000;
.text : { *(.text) }
.rodata : { *(.rodata) }
. = 0x801CB000;
.data : { *(.data) }
. = 0xD0015500;
.bss : { *(.bss) }
}
The elf file does contain symbols from this section though:
Symbol table '.symtab' contains 85 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 800b5964 0 SECTION LOCAL DEFAULT 1...
and later there is my .text section:
5: 80132000 0 SECTION LOCAL DEFAULT 5...
Somehow I am not defining the section properly in the linker script file. Because it doesn't have a traditional name like .text I'm missing something that is stopping it getting into the sections to "load" into the elf and hence the hex, although IDA Pro loading the elf is showing the sections correctly placed, and their contents.
Posting in RE because I'm patching binaries with a combination of C and asm.
Thanks!
tricore-objcopy --set-start=0x80000000 -O ihex test1.elf test1.hex
is the conversion I am using from elf to hex..jfuel
so seems to be something else).section .jfuel , "ax" j translatefuel
where ax replaced x and now the hex file contains everything.