Skip to content

[AVR] llvm-objdump should automatically select the instruction set #146451

Open
@benshi001

Description

@benshi001

Given a simple test program:

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

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.

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.

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions