Issue 146451
Summary [AVR] llvm-objdump should automatically select the instruction set
Labels new issue
Assignees benshi001
Reporter benshi001
    Given a simple test program:
```c++
int adiw(int a) {
	return a + 51;
}
```

Build it with `clang a.c --target=avr -mmcu=avr2 -c -O3`, and then disassemble it with `llvm-objdump -d a.o`, we see
```asm
a.o:	file format elf32-avr

Disassembly of section .text:

00000000 <adiw>:
       0: c3 96 08 95  	<unknown>
```

We must specify `--mcpu=avr2` to `llvm-objdump` explicitly to make `adiw` correctly  decoded.
```asm
a.o:	file format elf32-avr

Disassembly of section .text:

00000000 <adiw>:
       0: c3 96        	adiw	r24, 0x33
       2: 08 95        	ret
```


However the generated object file does contain the `avr2` family information.
```bash
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data: 2's complement, little endian
  Version: 1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type: REL (Relocatable file)
  Machine:                           Atmel AVR 8-bit microcontroller
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          284 (bytes into file)
  Flags:                             0x82, EF_AVR_ARCH_AVR2, relaxable
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers: 5
  Section header string table index: 1
```

So the `llvm-objdump` should automatically select the avr family according to ELF header, other than rely on user's explicit specification. 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to