diff options
| author | 2023-06-17 23:26:45 +0200 | |
|---|---|---|
| committer | 2023-06-17 23:26:45 +0200 | |
| commit | 962ad175aee634274b408ead38b13e6bc90e2fe7 (patch) | |
| tree | cfda733adf56ed12e829f594e0b6d66f0a1a7a70 /ir.c | |
| parent | ec28e9057e84b92acabb7ebf9122af59738917ad (diff) | |
basic ELF output
Diffstat (limited to 'ir.c')
| -rw-r--r-- | ir.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include "ir.h" +#include "common.h" uchar type2cls[NTYPETAG]; uchar cls2siz[KF8+1]; @@ -191,6 +192,22 @@ mkdatref(uint siz, uint align, const void *bytes, uint n, bool deref) return mkref(RXCON, addcon(&(struct xcon){.isdat = 1, .deref = deref, .dat = dattab.n - 1})); } +const char * +xcon2sym(int ref) +{ + extern const char *intern(const char *); + char buf[32]; + struct wbuf wbuf = MEMBUF(buf, sizeof buf); + struct xcon *con = &conht[ref]; + + assert(con->isdat || con->issym); + if (con->issym) return con->sym; + bfmt(&wbuf, ".L.%d", con->dat); + ioputc(&wbuf, 0); + assert(!wbuf.err); + return intern(buf); +} + struct instr mkalloca(uint siz, uint align) { |