Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Update ELF psABI spec to include new ABI types.
Browse files Browse the repository at this point in the history
  • Loading branch information
scylaac committed Oct 13, 2021
1 parent 98ea7f0 commit a775b9e
Show file tree
Hide file tree
Showing 2 changed files with 283 additions and 61 deletions.
168 changes: 139 additions & 29 deletions docs/LoongArch-ELF-ABI-CN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ v1.00

== ELF 目标文件

=== EI_CLASS: ELF 文件格式
=== `EI_CLASS`: ELF 文件格式

[%header,cols="2m,^1,^3"]
[%header,cols="2m,^1m,^3"]
|===
|EI_CLASS
|枚举值
Expand All @@ -172,62 +172,90 @@ v1.00
|64 位 ELF 格式
|===

=== e_machine: 体系结构 ID
=== `e_machine`: 体系结构 ID

`LoongArch (258)`

=== `e_flags`: ABI 类型标记

LoongArch (258)
[%header,cols="1,1,1"]
|=========================================
|`[1:0]` 位 | `[5:2]` 位 | `[31:6]` 位

=== e_flags: ABI 变体标记
| 整型 ABI | 浮点 / 扩展 ABI | (保留)
|=========================================

`e_flags[5:0]` 标记了 ELF 目标文件使用的 ABI 类型。
其中, `e_flags[1:0]` 标记整型 ABI, `e_flags[5:2]` 标记浮点 / 扩展 ABI。

.整型 ABI 标记
[%header,cols="2m,^1,^3"]
|===
|ABIs
|整型 ABI 名称
|枚举值
|含义

|lp32
|0x1
|32 位整型 ABI,仅支持软件浮点数
|lp64
|`0x3`
|使用 64 位通用寄存器和栈传参

|ilp32
|`0x1`
|使用 32 位通用寄存器和栈传参

|(保留值)
|0x2
|`0x2` `0x0`
|--
|===

|lp64
|0x3
|64 位整型 ABI,支持双精度硬件浮点数
.浮点 / 扩展 ABI 标记
[%header,cols="2m,^1,^3"]
|===
|浮点 / 扩展 ABI 名称
|枚举值
|含义

|lp32f
|0x4
|32 位整型 ABI,支持单精度硬件浮点数
|double
|`0x0`
|使用 64 位浮点寄存器传参

|soft
|`0x3`
|不使用浮点寄存器传参

|lp32d
|0x5
|32 位整型 ABI,支持双精度硬件浮点数
|single
|`0x2`
|使用 32 位浮点寄存器传参

|(保留值)
|0x6 --
|`0x1` `0x4 - 0xf`
|--
|===

=== ABI 版本
[[abi-versioning]]
=== `e_ident [EI_ABIVERSION]`: ABI 版本

[%header,cols="2m,^1,^5"]
[%header,cols="2,^1,^5,^1"]
|===
|ABI 版本
|枚举值
|描述
|动态链接器版本后缀

|v0
|0
|`v0`
|`0`
|支持具有栈操作语义的重定位类型(旧版兼容)
|`.1`

|v1
|1
|`v1`
|`1`
|新版重定位类型
|`.2`

|--
|2 --
|保留
|`--`
|`2 --`
|(保留值)
|`.3 --`
|===

== 重定位类型
Expand Down Expand Up @@ -524,3 +552,85 @@ LoongArch (258)
|GNU C++ vtable 支持
|
|===

== 编译器选项和路径惯例

=== 编译器选项

以下编译器选项的最终效应包括:

1. 配置使用的 ABI 类型

2. 配置使用的 ISA 扩展

3. 配置处理器型号相关的调优参数

.编译器选项列表:
[%header,cols="^1m,^2,^7"]
|===
|选项
|可用值
|描述

|-march=
|`native` `loongarch64` `la464`
|选择目标 CPU (隐含默认 ABI 类型、ISA 扩展和调优参数)

|-mtune=
|`native` `loongarch64` `la464`
|选择目标 CPU 的性能调优参数

|-mabi=
|`lp64` `ilp32`
|选择整型 ABI 类型

|-mfloat-abi=
|`double` `single` `soft`
|选择浮点 / 扩展 ABI 类型

|-mfpu=
|`double` `single` `none`
|选择编译器可用的浮点 / 扩展指令集

|-msoft-float
|`--`
|`-mfloat-abi=soft -mfpu=none` 的简写

|-msingle-float
|`--`
|`-mfloat-abi=single -mfpu=single` 的简写

|-mdouble-float
|`--`
|`-mfloat-abi=double -mfpu=double` 的简写
|===

=== 动态链接器路径

.各 ABI 类型对应的动态连接器路径惯例:
[%header,cols="^1m,^3m"]
|===
|ABI 类型
|Glibc 动态链接器路径

|lp64/double
|/lib64/ld-linux-loongarch-lp64-df.so.<abiversion>

|lp64/single
|/lib64/ld-linux-loongarch-lp64-sf.so.<abiversion>

|lp64/soft
|/lib64/ld-linux-loongarch-lp64-nf.so.<abiversion>

|ilp32/double
|/lib32/ld-linux-loongarch-ilp32-df.so.<abiversion>

|ilp32/single
|/lib32/ld-linux-loongarch-ilp32-sf.so.<abiversion>

|ilp32/soft
|/lib32/ld-linux-loongarch-ilp32-nf.so.<abiversion>
|===

表中 `<abiversion>` 与 ELF文件编码的 `e_ident[EI_ABIVERSION]` 一一对应,
参见 <<abi-versioning, ABI 版本>> 。
Loading

0 comments on commit a775b9e

Please sign in to comment.