Skip to content

Incorrect target in .elf attributes #622

@EasyBartholomew

Description

@EasyBartholomew

Summary
When compiling for cortex-m23 it has different attributes in elf file.

To Reproduce

  1. Compile any binary for cortex-m23, I did it with these options:
--target=arm-none-eabi
-march=armv8-m.base
-mcpu=cortex-m23
-mthumb
-mfpu=none 
-mfloat-abi=soft
  1. Check it with llvm-readelf or with arm-none-eabi-readelf. They give slightly different but the same output in fact.
$ llvm-readelf -A blinker.elf
BuildAttributes {
  FormatVersion: 0x41
  Section 1 {
    SectionLength: 64
    Vendor: aeabi
    Tag: Tag_File (0x1)
    Size: 54
    FileAttributes {
      Attribute {
        Tag: 67
        TagName: conformance
        Value: 2.09
      }
      Attribute {
        Tag: 5
        TagName: CPU_name
        Value: cortex-m0
      }
      Attribute {
        Tag: 6
        Value: 12
        TagName: CPU_arch
        Description: ARM v6S-M
      }
      Attribute {
        Tag: 7
        Value: 77
        TagName: CPU_arch_profile
        Description: Microcontroller
      }
      Attribute {
        Tag: 8
        Value: 0
        TagName: ARM_ISA_use
        Description: Not Permitted
      }
      Attribute {
        Tag: 9
        Value: 1
        TagName: THUMB_ISA_use
        Description: Thumb-1
      }
      Attribute {
        Tag: 14
        Value: 0
        TagName: ABI_PCS_R9_use
        Description: v6
      }
      Attribute {
        Tag: 17
        Value: 1
        TagName: ABI_PCS_GOT_use
        Description: Direct
      }
      Attribute {
        Tag: 18
        Value: 4
        TagName: ABI_PCS_wchar_t
        Description: 4-byte
      }
      Attribute {
        Tag: 20
        Value: 1
        TagName: ABI_FP_denormal
        Description: IEEE-754
      }
      Attribute {
        Tag: 21
        Value: 0
        TagName: ABI_FP_exceptions
        Description: Not Permitted
      }
      Attribute {
        Tag: 23
        Value: 3
        TagName: ABI_FP_number_model
        Description: IEEE-754
      }
      Attribute {
        Tag: 24
        Value: 1
        TagName: ABI_align_needed
        Description: 8-byte alignment
      }
      Attribute {
        Tag: 25
        Value: 1
        TagName: ABI_align_preserved
        Description: 8-byte data alignment
      }
      Attribute {
        Tag: 26
        Value: 2
        TagName: ABI_enum_size
        Description: Int32
      }
      Attribute {
        Tag: 30
        Value: 4
        TagName: ABI_optimization_goals
        Description: Aggressive Size
      }
      Attribute {
        Tag: 34
        Value: 0
        TagName: CPU_unaligned_access
        Description: Not Permitted
      }
      Attribute {
        Tag: 38
        Value: 1
        TagName: ABI_FP_16bit_format
        Description: IEEE-754
      }
    }
  }
}

Expected behavior
.elf contains correct attributes like if it was compiled with arm-none-eabi toolchain

Actual behavior
Unexpectedly for me it contains CPU_name equal to cortex-m0

Environment
Arm toolchain for embedded 21.1.x (was tested with with pre-compiled version (tarball from github) and with self-compiled, got the same result). My system is Ubuntu 25.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions