aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-03 15:48:39 +1300
committerAndrew Chambers <[email protected]>2021-10-03 15:48:39 +1300
commit20a290ec8fc4a841b121b44607f0a8af6cfa063b (patch)
tree7b7d37ddf6eefe3fe3ab2d3da33d860520cfd001
parent00d2c37ee3fce0e50aed2fffa6cc57e6da269fa1 (diff)
Work on symbol table.
-rw-r--r--main.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/main.c b/main.c
index 709e026..d5c7ead 100644
--- a/main.c
+++ b/main.c
@@ -226,11 +226,16 @@ static void prepass(void) {
static void addtosymtab(Symbol *sym) {
Elf64_Sym elfsym;
+ int stype;
+ int sbind;
+ stype = (sym->section->hdr.sh_flags & SHF_EXECINSTR) ? STT_FUNC : STT_OBJECT;
+ sbind = sym->global ? STB_GLOBAL : STB_LOCAL;
memset(&elfsym, 0, sizeof(elfsym));
elfsym.st_name = elfstr(strtab, sym->name);
elfsym.st_size = sym->size;
elfsym.st_value = sym->offset;
+ elfsym.st_info = ELF32_ST_BIND(sbind) | ELF32_ST_TYPE(stype);
elfsym.st_shndx = sym->section->idx;
secaddbytes(symtab, (uint8_t *)&elfsym, sizeof(Elf64_Sym));
}