shithub: scc

Download patch

ref: ca44f53e072e0a0eea376a5f7a7ddfe754ccc184
parent: 1fc37685fd10a06a75bab2f6a147dd6e810b2b7f
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Oct 26 14:08:08 EDT 2021

libmach: Add skeleton for elf64

--- a/src/libmach/Makefile
+++ b/src/libmach/Makefile
@@ -1,7 +1,8 @@
 .POSIX:
 
 DIRS =\
-	coff32
+	coff32\
+	elf64\
 
 PROJECTDIR =../..
 include $(PROJECTDIR)/scripts/rules.mk
--- /dev/null
+++ b/src/libmach/elf64/Makefile
@@ -1,0 +1,11 @@
+.POSIX:
+
+PROJECTDIR =../../..
+include $(PROJECTDIR)/scripts/rules.mk
+
+OBJS =\
+	elf64.o \
+
+all: $(OBJS)
+
+include deps.mk
--- /dev/null
+++ b/src/libmach/elf64/deps.mk
@@ -1,0 +1,4 @@
+#deps
+elf64.o: $(INCDIR)/scc/scc/mach.h
+elf64.o: ../libmach.h
+elf64.o: elf64.h
--- /dev/null
+++ b/src/libmach/elf64/elf64.c
@@ -1,0 +1,21 @@
+#include <stdio.h>
+
+#include <scc/mach.h>
+
+#include "../libmach.h"
+#include "elf64.h"
+
+struct objops coff32 = {
+	.probe = NULL,
+	.new = NULL,
+	.read = NULL,
+	.getidx = NULL,
+	.setidx = NULL,
+	.pc2line = NULL,
+	.strip = NULL,
+	.del = NULL,
+	.write = NULL,
+	.getsym = NULL,
+	.getsec = NULL,
+	.loadmap = NULL,
+};
--- /dev/null
+++ b/src/libmach/elf64/elf64.h
@@ -1,0 +1,16 @@
+extern int elf64new(Obj *);
+extern int elf64read(Obj *, FILE *);
+extern int elf64setidx(long, char **, long *, FILE *);
+extern int elf64getidx(long *, char ***, long **, FILE *);
+extern int elf64pc2line(Obj *, unsigned long long , char *, int *);
+extern int elf64strip(Obj *);
+extern void elf64del(Obj *);
+extern int elf64write(Obj *, Map *, FILE *);
+extern int elf64probe(unsigned char *, char **);
+
+extern int elf64xsetidx(int long , char *[], long [], FILE *);
+extern int elf64xgetidx(int, long *, char ***, long **, FILE *);
+
+extern Symbol *elf64getsym(Obj *, int *, Symbol *);
+extern Section *elf64getsec(Obj *, int *, Section *);
+extern Map *elf64loadmap(Obj *, FILE *);
--- a/src/libmach/libmach.h
+++ b/src/libmach/libmach.h
@@ -7,6 +7,7 @@
 
 enum objformat {
 	COFF32,
+	ELF64,
 	NFORMATS,
 };
 
@@ -65,3 +66,4 @@
 /* globals */
 extern Objops *objops[];
 extern Objops coff32;
+extern Objops elf64;
--- a/src/libmach/mach.c
+++ b/src/libmach/mach.c
@@ -6,5 +6,6 @@
 
 Objops *objops[] = {
 	[COFF32] = &coff32,
+	[ELF64] = &elf64,
 	[NFORMATS] = NULL,
 };