[llvm] [llvm-objdump][AVR] Detect AVR architecture from ELF flags for disassembling (PR #174731)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 00:48:57 PST 2026


================
@@ -0,0 +1,50 @@
+# REQUIRES: avr-registered-target
+
+## When --mattr and --mcpu are both empty, disassemble elf with EFlag-derived feature.
+# RUN: yaml2obj -DARCHVERSION=AVR1 %s -o %t.avr1
+# RUN: llvm-objdump -d %t.avr1 | FileCheck %s --check-prefixes=UNKNOWN
+# RUN: yaml2obj -DARCHVERSION=AVR3 %s -o %t.avr3
+# RUN: llvm-objdump -d %t.avr3 | FileCheck %s --check-prefixes=ALL
+
+## If --mattr or --mcpu is specified, don't default to the file's EFlag-derived feature.
+# RUN: llvm-objdump -d --mattr=+avr3 %t.avr1 | FileCheck %s --check-prefixes=ALL
+# RUN: llvm-objdump -d --mcpu=avr3 %t.avr1 | FileCheck %s --check-prefixes=ALL
+
+# UNKNOWN:         <_start>:
+# UNKNOWN-COUNT-2:   <unknown>
+# UNKNOWN:           rjmp    .-2
+
+# ALL:      <_start>:
+# ALL-NEXT:   call    0x0
+# ALL-NEXT:   jmp     0x0
+# ALL-NEXT:   rjmp    .-2
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_AVR
+  Flags:           [ EF_AVR_ARCH_[[ARCHVERSION]] ]
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Content:         0E9400000C940000FFCF
+  - Name:            .rela.text
----------------
jh7370 wrote:

Are the relocations actually needed for correct disassembly? Would it be better to make the file an `ET_EXEC` and omit the this section?

https://github.com/llvm/llvm-project/pull/174731


More information about the llvm-commits mailing list