scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

elf64.c (567B)


      1 #include <stdio.h>
      2 
      3 #include <scc/mach.h>
      4 
      5 #include "../libmach.h"
      6 #include "elf64.h"
      7 
      8 struct objops elf64 = {
      9 	.probe = elf64probe,
     10 	.new = elf64new,
     11 	.read = elf64read,
     12 	.getidx = NULL,
     13 	.setidx = NULL,
     14 	.pc2line = NULL,
     15 	.strip = NULL,
     16 	.del = elf64del,
     17 	.write = NULL,
     18 	.getsym = elf64getsym,
     19 	.getsec = elf64getsec,
     20 	.loadmap = NULL,
     21 };
     22 
     23 char *
     24 elf64str(Obj *obj, int n, long stroff)
     25 {
     26 	char *tbl;
     27 	size_t siz;
     28 	struct elf64 *elf;
     29 
     30 	elf = obj->data;
     31 
     32 	tbl = elf->strtbl[n];
     33 	siz = elf->strsiz[n];
     34 
     35 	if (!tbl || siz < stroff)
     36 		return "";
     37 	return &tbl[stroff];
     38 }