Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readelf: Add support for LoongArch specific e_flags #1532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

haowuge
Copy link

@haowuge haowuge commented Nov 17, 2024

Hello, I have added support for the LoongArch architecture to readelf, primarily referencing RISC-V/LLVM related commits.

EM_LOONGARCH is officially registered as e_machine 258.
Reference: llvm/llvm-project@e53e6ec
Reference1: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc
Reference2: llvm/llvm-project@4e2dfd3

❯ /usr/obj/usr/bsrc/amd64.amd64/usr.bin/readelf/readelf -h ~/CNPROJ/dwz
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            NONE
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           LoongArch
  Version:                           0x1
  Entry point address:               0x3f68
  Start of program headers:          64 (bytes into file)
  Start of section headers:          266304 (bytes into file)
  Flags:                             0x43, DOUBLE-FLOAT, OBJ-v1
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         27
  Section header string table index: 26
❯
❯ llvm-readelf -h ~/CNPROJ/dwz
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           LoongArch
  Version:                           0x1
  Entry point address:               0x3F68
  Start of program headers:          64 (bytes into file)
  Start of section headers:          266304 (bytes into file)
  Flags:                             0x43, DOUBLE-FLOAT, OBJ-v1
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         27
  Section header string table index: 26
@gmshake
Copy link
Contributor

gmshake commented Nov 17, 2024

As far as I know, FreeBSD does not ( or have plans to ) support LoongArch, but this is for elf tools so I guess it is OK to have this feature in. CC @bsdimp and @kostikbel .

@brooksdavis
Copy link
Contributor

This should likely to upstream https://sourceforge.net/p/elftoolchain/wiki/Home/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants