I tried to disas atmega328p elf files like this.
avr-objdump -d -Maddr16,data16 target/avr-atmega328p/release/sample.elf (git)-[serial_echo_interrupt]
target/avr-atmega328p/release/sample.elf: file format elf32-avr
Disassembly of section .text:
00000000 <__vectors>:
0: 0c 94 34 00 jmp 0x68 ; 0x68 <__ctors_end>
4: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
8: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
c: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
10: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
but the program address is mismatch because the flash width is 16 bit.
Do you know how to set 16-bit flash width?
the program address is mismatch because the flash width is 16 bit.
Do you know how to set 16-bit flash width?
GNU tools are using byte addresses, and there is no way to change that. This applies to:
Addresses displayed with tools like objdump
, readelf
, nm
, etc.
Addresses used in the linker description file.
Addresses displayed in the map file as of avr-gcc -Wl,-Map,source.map source.c ...
Addresses used by the compiler, e.g when you take the address of an object in SRAM (in .data
, .bss
) or in flash (.progmem
).
Addresses in options like -Ttext=0x1234
to specify the start of the text
section.
The only exception is when you are taking the address of a function in C/C++ which will be a word-address suitable for an indirect call via icall
.
As an aside, specifying an emulation like with objdump -m avr5
as proposed in the other answer won't change this in any way. You are disassembling an ELF file which knows the emulation anyways (as opposed to Intel HEX format which is agnostic).