Comments (10)
We can't drop support for R_RISCV_CALL as the ABI was fixed when we upstreamed glibc.
We could perhaps prefer R_RISCV_CALL_PLT and deprecate R_RISCV_CALL in future toolchains. However, this isn't a bug fix, this is an enhancement. As a practical matter, we only have one person supporting the entire toolchain, so there is no time available to do enhancement work like this. There is only time available to fix stuff that is broken. Perhaps at some point in the future we will have people available to look at issues like this.
from riscv-elf-psabi-doc.
from riscv-elf-psabi-doc.
@aswaterman Such optimizations can be applied on R_RISCV_CALL_PLT
, too (i386 x86-64 ppc{32,64} have similar optimizations). The preemptability is the property of the symbol, not the property of the relocation type. The evolution from powerpc ELFv1 to ELFv2 told me people did intend to assign such semantics to relocation types, but they found the semantics may be better handled on the symbol side.
from riscv-elf-psabi-doc.
call foo
always gives R_RISCV_CALL
; if you want R_RISCV_CALL_PLT
you have to write call foo@plt
.
from riscv-elf-psabi-doc.
I too see no justification for the distinction. It makes sense only on targets where there's a special ABI for calling into the PLT (typically, a register that must contain the GOT address, e.g. ebx on i386), in which case call points that aren't explicitly calling foo@PLT cannot be directed into a PLT thunk (a proper one - not an issue for the canonical non-PIC PLT thunk in a non-PIE main executable), and must be a link error (or a textrel) if the symbol is not locally defined.
from riscv-elf-psabi-doc.
@jrtc27 Sorry I made a mistake. I've changed the first sentence to use a C example instead.
from riscv-elf-psabi-doc.
I too see no justification for the distinction. It makes sense only on targets where there's a special ABI for calling into the PLT (typically, a register that must contain the GOT address, e.g. ebx on i386), in which case call points that aren't explicitly calling foo@PLT cannot be directed into a PLT thunk (a proper one - not an issue for the canonical non-PIC PLT thunk in a non-PIE main executable), and must be a link error (or a textrel) if the symbol is not locally defined.
Sometimes it's useful to ensure this specific call cannot be pre-empted. The FreeBSD libc at least makes use of this; you can work around the issue by defining a local symbol alias, but not distinguishing between call foo
and call foo@plt
would break this.
from riscv-elf-psabi-doc.
The RISC-V glibc port relies on the same property @jrtc27 mentioned.
from riscv-elf-psabi-doc.
Also I suppose a reason for the compiler not to emit call foo@plt
with -fno-PIC
is that it may have performed optimisations on the assumption that foo
cannot be preempted, which is no longer true if you link it as a shared library (and that may well link just fine, especially if you used -fPIE and aren't using global non-static variables).
from riscv-elf-psabi-doc.
The undef weak check is to prevent relocation truncated errors when you call a weak function that does not get defined, and your code is compiled for an address above 0x80000000 on a 64-bit target. For an undefined weak function, we need to make the target address 0. But this is a pc-relative reloc, which has a 2GB range (medlow/medany) which means we can't actually reach 0 from any address above 0x80000000. So we detect this case and rewrite the instruction and reloc to be x0 relative instead of pc-relative, and then we can resolve the reloc without error as address 0 is reachable from x0. There are testcases for this in the ld testsuite, see for instance ld/testsuite/ld-riscv-elf/weakref*.
As a practical matter, since all linux code is compiled for a base address of 0, this only get triggered by embedded developers, so we only needed a fix for R_RISCV_CALL.
from riscv-elf-psabi-doc.
Related Issues (20)
- Collect psABI requirements for next release
- Alignment of __int128 on ILP32 HOT 7
- Question on calculation for HI20 HOT 2
- Question on calculation for HI20 HOT 1
- Clarification of rules for flattening structs containing arrays of empty records HOT 3
- 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
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.