scc

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

elf64.c (587B)


      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 	.type = elf64type,
     10 	.probe = elf64probe,
     11 	.new = elf64new,
     12 	.read = elf64read,
     13 	.getidx = NULL,
     14 	.setidx = NULL,
     15 	.pc2line = NULL,
     16 	.strip = NULL,
     17 	.del = elf64del,
     18 	.write = NULL,
     19 	.getsym = elf64getsym,
     20 	.getsec = elf64getsec,
     21 	.loadmap = NULL,
     22 };
     23 
     24 char *
     25 elf64str(Obj *obj, int n, long stroff)
     26 {
     27 	char *tbl;
     28 	size_t siz;
     29 	struct elf64 *elf;
     30 
     31 	elf = obj->data;
     32 
     33 	tbl = elf->strtbl[n];
     34 	siz = elf->strsiz[n];
     35 
     36 	if (!tbl || siz < stroff)
     37 		return "";
     38 	return &tbl[stroff];
     39 }