@chrQuote from: chr on 17 / August / 2008, 00:53:48Mh, I compared with my file. I got:CONTENTS, ALLOC, LOAD, CODESo, ALLOC & LOAD sections are missing?if i understand your last post correctly, i changed disassemble.pl like this:Code: [Select]print "create elf file\n";`$objcopy --change-addresses=$offset -I binary -O elf32-littlearm -B arm $binfile $binfile.elf`;`$objcopy --set-section-flags .data=load $binfile.elf`; <--- ADDED THIS`$objcopy --set-section-flags .data=code $binfile.elf`; but "arm-elf-objdump -x dump.bin.elf" output remains the same...
Mh, I compared with my file. I got:CONTENTS, ALLOC, LOAD, CODE
print "create elf file\n";`$objcopy --change-addresses=$offset -I binary -O elf32-littlearm -B arm $binfile $binfile.elf`;`$objcopy --set-section-flags .data=load $binfile.elf`; <--- ADDED THIS`$objcopy --set-section-flags .data=code $binfile.elf`;
--set-section-flags section=flags Set the flags for the named section. The flags argument is a comma separated string of flag names. The recognized names are alloc, contents, load, noload, readonly, code, data, rom, share, and debug. You can set the contents flag for a section which does not have contents, but it is not meaningful to clear the contents flag of a section which does have contents--just remove the section instead. Not all flags are meaningful for all object file for? mats.
From the objcopy man page: --set-section-flags section=flags Set the flags for the named section. The flags argument is a comma separated string of flag names. The recognized names are alloc, contents, load, noload, readonly, code, data, rom, share, and debug. You can set the contents flag for a section which does not have contents, but it is not meaningful to clear the contents flag of a section which does have contents--just remove the section instead. Not all flags are meaningful for all object file for? mats.
print "create elf file\n";`$objcopy --change-addresses=$offset -I binary -O elf32-littlearm -B arm $binfile $binfile.elf`;`$objcopy --set-section-flags .data=content,alloc,load,code $binfile.elf`;
Sections:Idx Name Size VMA LMA File off Algn 0 .data 0036a640 ff810000 ff810000 00000034 2**0 CONTENTS, ALLOC, LOAD, CODESYMBOL TABLE:ff810000 l d .data 00000000 ff810000 g .data 00000000 _binary_dump_bin_startffb7a640 g .data 00000000 _binary_dump_bin_end0036a640 g *ABS* 00000000 _binary_dump_bin_size
.text.org 0.align 2.globl _start// stubs_2_elf.S// (c) 2008 chr// GPL v3+// create elf file from a binary blob// and mix with symbols from stubs files// compile with:// arm-linux-gnu-gcc -Wl,-N,-Ttext,0xff810000 -nostdlib stubs_2_elf.S -o rom.elf// cheat around gdb ignoring absolute symbolshere = .#define offs 0xff810000#define NSTUB(name, addr) name = here + addr - offs#define NHSTUB NSTUB#define __STUBS_ASM__H__#include "stubs_entry.S"#include "stubs_entry_2.S"// test test ...NSTUB(Jump, 0xff81000c)NSTUB(Whatever, 0xff810164)// include rom dump_start:.textblob_start:.incbin "PRIMARY.BIN"blob_end:
#ifndef __STUBS_ASM__H__#define __STUBS_ASM__H__
#endif
Disassembly of section .text:ff810000 <_start>:ff810000: ea000001 b ff81000c <Jump>ff810004: 6e6f6167 powvsez f6, f7, f7ff810008: 796f7369 stmvcdb pc!, {r0, r3, r5, r6, r8, r9, ip, sp, lr}^ff81000c <Jump>:ff81000c: e59f1150 ldr r1, [pc, #336] ; ff810164 <Whatever>ff810010: e3a00000 mov r0, #0 ; 0x0ff810014: e5810000 str r0, [r1]ff810018: e3a01078 mov r1, #120 ; 0x78ff81001c: ee011f10 mcr 15, 0, r1, cr1, cr0, {0}ff810020: e3a01000 mov r1, #0 ; 0x0ff810024: ee071f9a mcr 15, 0, r1, cr7, cr10, {4}
primary.elf: file format elf32-littlearmDisassembly of section .data:ffc00000 <_binary_PRIMARY_BIN_start>: 0: e3a00002 mov r0, #2 ; 0x2 4: ea000012 b ffc00054 <_binary_PRIMARY_BIN_start+0x54> 8: 79706f43 ldmdbvc r0!, {r0, r1, r6, r8, r9, sl, fp, sp, lr}^ c: 68676972 stmdavs r7!, {r1, r4, r5, r6, r8, fp, s
primary.elf: file format elf32-littlearmDisassembly of section .data:ffc00000 <_binary_PRIMARY_BIN_start>:ffc00000: e3a00002 mov r0, #2 ; 0x2ffc00004: ea000012 b ffc00054 <_binary_PRIMARY_BIN_start+0x54>ffc00008: 79706f43 ldmdbvc r0!, {r0, r1, r6, r8, r9, sl, fp, sp, lr}^ffc0000c: 68676972 stmdavs r7!, {r1, r4, r5, r6, r8, fp, sp, lr}^
The funny thing is, if I remove that one last byte from the a530 dump, it works like a charm! Have I encountered a bug or are we just not using these tools properly?
I have binutils-2.18.tar.gz gcc-3.4.6.tar.bz2 gdb-6.8.tar.gz set up on 64-bit Ubuntu Hardy.
Started by Daniel Moore Feature Requests
Started by Hardware_Hacker General Discussion and Assistance
Started by pigeonhill Creative Uses of CHDK