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

Commit

Permalink
Fix toolchain conventions and psABI document.
Browse files Browse the repository at this point in the history
  • Loading branch information
scylaac committed Nov 16, 2021
1 parent 19e3e88 commit 436f21a
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 197 deletions.
90 changes: 43 additions & 47 deletions docs/LoongArch-ELF-ABI-CN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ v1.00

== C 语言数据类型规格

.lp64 数据模型 (对应基础 ABI 类型:`lp64d` `lp64f` `lp64s`)
.LP64 数据模型 (对应基础 ABI 类型:`lp64d` `lp64f` `lp64s`)
[%header,cols="3,^1,^1"]
|===
|标量类型
Expand Down Expand Up @@ -139,7 +139,7 @@ v1.00
|8
|===

.ilp32 数据模型 (对应基础 ABI 类型:`ilp32d` `ilp32f` `ilp32s`)
.ILP32 数据模型 (对应基础 ABI 类型:`ilp32d` `ilp32f` `ilp32s`)
[%header,cols="3,^1,^1"]
|===
|标量类型
Expand Down Expand Up @@ -223,39 +223,43 @@ v1.00
|枚举值 (`e_flags[2:0]`)
|含义

|lp64d
|`0x3`
|使用 64 位通用寄存器,64位浮点寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)

|lp64f
|`0x2`
|使用 64 位通用寄存器,32位浮点寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)
|
|`0x0`
|保留值

|lp64s
|`0x1`
|使用 64 位通用寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位)

|ilp32d
|`0x7`
|使用 32 位通用寄存器,64位浮点寄存器和栈传参
数据模型为 "ilp32"(`int`,`long` 和指针类型宽度为32位
|lp64f
|`0x2`
|使用 64 位通用寄存器,32位浮点寄存器和栈传参
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位

|ilp32f
|`0x6`
|使用 32 位通用寄存器,32位浮点寄存器和栈传参,
数据模型为 "ilp32"(`int`,`long` 和指针类型宽度为32位)
|lp64d
|`0x3`
|使用 64 位通用寄存器,64位浮点寄存器和栈传参,
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位)

|
|`0x4`
|保留值

|ilp32s
|`0x5`
|使用 32 位通用寄存器和栈传参,
数据模型为 "ilp32"(`int`,`long` 和指针类型宽度为32位)
数据模型为 ILP32(`int`,`long` 和指针类型宽度为32位)

|
|`0x4` `0x0`
|保留值
|ilp32f
|`0x6`
|使用 32 位通用寄存器,32位浮点寄存器和栈传参,
数据模型为 ILP32(`int`,`long` 和指针类型宽度为32位)

|ilp32d
|`0x7`
|使用 32 位通用寄存器,64位浮点寄存器和栈传参,
数据模型为 ILP32(`int`,`long` 和指针类型宽度为32位)
|===

.ABI 扩展特性标记
Expand All @@ -265,7 +269,7 @@ v1.00
|枚举值 (`e_flags[5:3]`)
|含义

|default
|base
|`0x0`
|默认,无扩展特性

Expand All @@ -275,31 +279,26 @@ v1.00
|===

[[abi-versioning]]
`e_flags[7:6]` 标记了 ELF 目标文件使用的 ABI 版本,
它和动态链接器标准文件名 (`ld-*.so`) 的版本后缀一一对应。
`e_flags[7:6]` 标记了 ELF 目标文件使用的 ABI 版本。

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

|`v0`
|`0x0`
|支持具有栈操作语义的重定位类型
|`.0`

|`v1`
|`0x1`
|按需保留
|`.1`

|
|`0x2` `0x3`
|保留值
|`.2` `.3`
|===


Expand Down Expand Up @@ -608,30 +607,27 @@ v1.00
|操作系统 / C 库
|Glibc 动态链接器路径

|lp64d |default
|lp64d |base
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64d.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64d.so.1

|lp64f |default
|lp64f |base
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64f.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64f.so.1

|lp64s |default
|lp64s |base
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64s.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64s.so.1

|ilp32d |default
|ilp32d |base
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32d.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32d.so.1

|ilp32f |default
|ilp32f |base
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32f.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32f.so.1

|ilp32s |default
|ilp32s |base
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32s.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32s.so.1
|===

表中 `<abiversion>` 与 ELF文件编码的 `e_flags[7:6]` 一一对应,
参见 <<abi-versioning, ABI 版本>> 。
91 changes: 43 additions & 48 deletions docs/LoongArch-ELF-ABI-EN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Static registers are also known as callee-saved registers.

== Type Size and Alignment

.lp64 Data Model (base ABI types: `lp64d` `lp64f` `lp64s`)
.LP64 Data Model (base ABI types: `lp64d` `lp64f` `lp64s`)
[%header,cols="3,^1,^1"]
|===
|Scalar type
Expand Down Expand Up @@ -138,7 +138,7 @@ Static registers are also known as callee-saved registers.
|8
|===

.ilp32 Data Model (base ABI types: `ilp32d` `ilp32f` `ilp32s`)
.ILP32 Data Model (base ABI types: `ilp32d` `ilp32f` `ilp32s`)
[%header,cols="3,^1,^1"]
|===
|Scalar type
Expand Down Expand Up @@ -220,39 +220,43 @@ The ABI type of an ELF object is uniquely identified by `e_flags[7:0]` in its he
|Value of `e_flags[2:0]`
|Description

|lp64d
|`0x3`
|Uses 64-bit GPRs, 64-bit FPRs and the stack for parameter passing.
Data model is "lp64", where `long` and pointers are 64-bit while `int` is 32-bit.

|lp64f
|`0x2`
|Uses 64-bit GPRs, 32-bit FPRs and the stack for parameter passing.
Data model is "lp64", where `long` and pointers are 64-bit while `int` is 32-bit.
|
|`0x0`
|(reserved)

|lp64s
|`0x1`
|Uses 64-bit GPRs and the stack for parameter passing.
Data model is "lp64", where `long` and pointers are 64-bit while `int` is 32-bit.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|ilp32d
|`0x7`
|Uses 32-bit GPRs, 64-bit FPRs and the stack for parameter passing.
Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
|lp64f
|`0x2`
|Uses 64-bit GPRs, 32-bit FPRs and the stack for parameter passing.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|ilp32f
|`0x6`
|Uses 32-bit GPRs, 32-bit FPRs and the stack for parameter passing.
Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
|lp64d
|`0x3`
|Uses 64-bit GPRs, 64-bit FPRs and the stack for parameter passing.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|
|`0x4`
|(reserved)

|ilp32s
|`0x5`
|Uses 32-bit GPRs and the stack for parameter passing.
Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.

|
|`0x4` `0x0`
|(reserved)
|ilp32f
|`0x6`
|Uses 32-bit GPRs, 32-bit FPRs and the stack for parameter passing.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.

|ilp32d
|`0x7`
|Uses 32-bit GPRs, 64-bit FPRs and the stack for parameter passing.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.
|===

.ABI Extension types
Expand All @@ -262,7 +266,7 @@ Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
|Value of `e_flags[5:3]`
|Description

|default
|base
|`0x0`
|No extra ABI features.

Expand All @@ -272,32 +276,26 @@ Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
|===

[[abi-versioning]]
`e_flags[7:6]` marks the ABI version of an ELF object,
it also corresponds to the version suffix of standard
program interpreters (`ld-*.so`).
`e_flags[7:6]` marks the ABI version of an ELF object.

.ABI Version
[%header,cols="2,^1,^5,^1"]
[%header,cols="2,^1,^5"]
|===
|ABI version
|Value
|Description
|Suffix of program interpreter filenames

|`v0`
|`0x0`
|Stack operands base relocation type.
|`.0`

|`v1`
|`0x1`
|Another relocation type IF needed.
|`.1`

|
|`0x2` `0x3`
|Reserved.
|`.2` `.3`
|===


Expand Down Expand Up @@ -606,30 +604,27 @@ with check 32-bit unsigned overflow
|Operating system / C library
|Program interpreter path

|lp64d |default
|lp64d |base
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64d.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64d.so.1

|lp64f |default
|lp64f |base
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64f.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64f.so.1

|lp64s |default
|lp64s |base
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64s.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64s.so.1

|ilp64d |default
|ilp32d |base
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32d.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32d.so.1

|ilp64f |default
|ilp32f |base
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32f.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32f.so.1

|ilp64s |default
|ilp32s |base
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32s.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32s.so.1
|===

Note: Each ABI version listed in <<abi-versioning, ABI versions>> corresponds
to a unique `<abiversion>`.
Loading

0 comments on commit 436f21a

Please sign in to comment.