Comments (8)
This is not a brand-new design; it is basically the same design as MIPS, PowerPC, Tilera, and Nios II.
The 0x800 offset is to maximize the displacement from the tp
register, since the ISA can address within +0x7ff and -0x800 of a register.
from riscv-elf-psabi-doc.
We intend to keep this standard for all platforms.
from riscv-elf-psabi-doc.
Thanks for the clarification, so I guess this should go into the ABI documentation as well?
from riscv-elf-psabi-doc.
Yeah, it should go into the psABI doc. If you have the time to write up a short description, please do; otherwise, let's keep this issue open until someone finds the time.
from riscv-elf-psabi-doc.
I noticed that TLS_TP_OFFSET
(used by initial-exec and local-exec) is not defined as a non 0 in glibc while reading a musl riscv patch.
/* The thread pointer points to the first static TLS block. */
#define TLS_TP_OFFSET 0
/* Dynamic thread vector pointers point 0x800 past the start of each
TLS block. */
#define TLS_DTV_OFFSET 0x800
On targets that define TLS_DTV_OFFSET
(m68k, powerpc{32,64} and mips), TLS_TP_OFFSET
is also defined.
/* The thread pointer points 0x7000 past the first static TLS block. */
#define TLS_TP_OFFSET 0x7000
/* Dynamic thread vector pointers point 0x8000 past the start of each
TLS block. */
#define TLS_DTV_OFFSET 0x8000
Take powerpc as an example: a@tprel
= st_value(a) - 0x7000
A load/write insn has an offset ranging from [-0x8000, 0x8000). This carefully picked TP offset allows it to load/write a TLS variable whose st_value ranges from [0,0x7000+0x8000).
Any reason riscv doesn't define TLS_TP_OFFSET
?
from riscv-elf-psabi-doc.
This support was written years ago at UC Berkeley. It may not be possible to determine why it was written this way.
The rv64 glibc ABI was frozen when we upstreamed it, so if this is an ABI change it is too late to change it. Technically the rv32 glibc ABI is not frozen yet, but having the rv32 ABI handle this differently from the rv64 ABI would be confusing and probably not worth the trouble.
It is odd that these numbers are 0 and 0x800. Maybe there was a mistake made somewhere along the way, or maybe there was a bug that they had to workaround and then forgot to change the numbers back. Probably no way to know for sure.
from riscv-elf-psabi-doc.
The offset of 0 may be preferable for making optimal use of the compressed ISA. With the offset of 0x800 you pretty much always need the 32-bit instruction forms for real-world code. In any case, this is ABI and can't be changed, and the motivations for using nonzero offsets is dubious at best.
from riscv-elf-psabi-doc.
The compressed ISA is probably the reason now that you point it out. That would explain the 0x800 offset.
Agreed that we aren't changing the ABI.
from riscv-elf-psabi-doc.
Related Issues (20)
- Specify relocation overflow checks HOT 1
- Specify a platform reserved register HOT 20
- Should calling convention also define ptrdiff_t? HOT 1
- Should we use lw/sw in push pop when we used ILP32, whether it's RV32 or RV64 HOT 3
- Operation semantics of __bf16 datatype HOT 2
- representation of GNU C fixed-size vectors HOT 4
- Deprecate R_RISCV_RVC_LUI? HOT 4
- Define GOT-Relative data relocation HOT 8
- Embedding R_RISCV_RELAX to another relocations HOT 7
- Define gp(x3) as global VLENB HOT 4
- Bitfield integer calling convention garbled
- Calling convention uses RV64GQ without definition or reference HOT 3
- Calling convention description of va_list et al. are unclear HOT 2
- Interpretation of floating-point types
- Linux ABI for Pointer Masking HOT 19
- New ABI for stack layout and frame pointer scheme HOT 4
- Change branch from "master" to "main" HOT 1
- Add CREL support HOT 3
- Add RELR support HOT 6
- Question about medlow's single 2 GiB address range HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riscv-elf-psabi-doc.