1
0
Fork 0
mirror of git://c9x.me/qbe.git synced 2026-06-20 12:32:34 +00:00
Compiler Backend
  • C 78.5%
  • OCaml 14.9%
  • Yacc 3.4%
  • Shell 1.3%
  • Python 1.3%
  • Other 0.6%
Find a file
Michael Forney e786f06032 rv64: use pc-relative addressing for globals
When extern was added, the rv64 code switched regular globals from
using la (a pseudo-instruction that uses pc-relative addressing
with auipc + addi) to lui + addi (absolute addressing). Presumably,
this was done to match gcc's output with -fPIC and -fno-PIC
respectively.  However, the key difference here is actually the
directive `%option pic` vs `%option nopic`, which determines whether
la uses the GOT or not.

This broke linking as PIE (for instance in compilers with
--enable-default-pie), even when there are no global references
outside the executable. The other architectures always use pc-relative
addressing, so rv64 should do the same.

It turns out there are more specific pseudo-instructions lla and
lga we can use instead. lla uses auipc+addi, and lga uses auipc+ld
from the GOT.

lga does not allow an offset. If you try to use one, it will assemble
without error, but fail at link time with

(.text+0x10): dangerous relocation: The addend isn't allowed for R_RISCV_GOT_HI20

For now, just add a check for this. A proper fix involves some
changes to rv64/isel like is done for amd64.
2026-06-08 12:01:16 +02:00
amd64 reduce memory footprint of strings 2026-05-13 09:03:09 +02:00
arm64 arm64: fix extern with offset 2026-06-08 11:56:20 +02:00
doc extern DYNCONST 2026-05-03 11:34:53 +02:00
minic minic: C23 doesn't allow bool as identifier 2025-03-16 11:27:49 +01:00
rv64 rv64: use pc-relative addressing for globals 2026-06-08 12:01:16 +02:00
test fix exponential behavior of defwidthle() 2026-05-05 15:22:12 +02:00
tools extern DYNCONST 2026-05-03 11:34:53 +02:00
.gitignore Global Value Numbering / Global Code Motion 2025-03-14 09:58:37 +01:00
abi.c add new target-specific abi0 pass 2022-10-03 10:41:03 +02:00
alias.c fix bug in alias analysis 2024-03-07 16:40:51 +01:00
all.h reduce memory footprint of strings 2026-05-13 09:03:09 +02:00
cfg.c fix typo in simplcfg 2026-01-13 20:36:23 +01:00
copy.c recognize more phis as copies 2026-05-06 22:14:45 +02:00
emit.c emit: fix aliasing-breaking pointer dereference via union 2026-06-07 09:52:52 +02:00
fold.c gvn/gcm review 2025-03-14 13:09:21 +01:00
gcm.c gvn/gcm review 2025-03-14 13:09:21 +01:00
gvn.c remove unused variable 2026-02-28 19:05:15 +01:00
ifopt.c If-conversion RFC 4 - x86 only (for now), use cmovXX 2026-01-13 18:11:30 +01:00
LICENSE update copyright years 2026-01-13 17:09:41 +01:00
live.c refine assertion in liveness analysis 2022-06-14 09:11:44 +02:00
load.c fix offset range check 2026-05-07 08:32:30 +02:00
main.c update debug flag list for gvn/gcm 2026-04-27 10:08:45 +02:00
Makefile .PHONY: check-amd64_win 2026-05-05 16:00:50 +02:00
mem.c relax one assert 2024-06-05 12:50:36 +02:00
ops.h ifopt simplifications 2026-01-13 18:11:37 +01:00
parse.c reduce memory footprint of strings 2026-05-13 09:03:09 +02:00
README 10 years of qbe! 2025-03-14 13:09:42 +01:00
rega.c reduce memory footprint of strings 2026-05-13 09:03:09 +02:00
simpl.c idup(Ins **, Ins *, ulong) -> idup(Blk *, Ins *, ulong) 2025-03-14 09:47:05 +01:00
spill.c fix jmp arg spilling 2026-01-13 17:09:41 +01:00
ssa.c gvn/gcm review 2025-03-14 13:09:21 +01:00
util.c reduce memory footprint of strings 2026-05-13 09:03:09 +02:00

QBE - Backend Compiler              http://c9x.me/compile/

doc/    Documentation.
minic/  An example C frontend for QBE.
tools/  Miscellaneous tools (testing).
test/   Tests.
amd64/
arm64/
rv64/   Architecture-specific code.

The LICENSE file applies to all files distributed.

- Compilation and Installation

Invoke make in this directory to create the executable
file qbe.  Install using 'make install', the standard
DESTDIR and PREFIX environment variables are supported.
Alternatively, you may simply copy the qbe binary.