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 4, 2021
1 parent 19e3e88 commit 898ad1c
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 152 deletions.
54 changes: 23 additions & 31 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 @@ -226,32 +226,32 @@ v1.00
|lp64d
|`0x3`
|使用 64 位通用寄存器,64位浮点寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位)

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

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

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

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

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

|
|`0x4` `0x0`
Expand All @@ -265,7 +265,7 @@ v1.00
|枚举值 (`e_flags[5:3]`)
|含义

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

Expand All @@ -275,31 +275,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 +603,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 版本>> 。
55 changes: 23 additions & 32 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 @@ -223,32 +223,32 @@ The ABI type of an ELF object is uniquely identified by `e_flags[7:0]` in its he
|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.
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.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|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.
Data model is ILP32, where `int`, `long` and pointers are 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.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.

|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`
Expand All @@ -262,7 +262,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 +272,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 +600,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 898ad1c

Please sign in to comment.