Browse Source

Refer to elf.h instead of a.out.h

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 4 years ago
parent
commit
8064173183
4 changed files with 20 additions and 10 deletions
  1. 14 4
      sys/include/elf.h
  2. 2 2
      sys/include/mach.h
  3. 3 3
      sys/src/libmach/executable.c
  4. 1 1
      sys/src/libmach/sym.c

+ 14 - 4
sys/include/elf.h

@@ -84,6 +84,16 @@ typedef struct {
 	uint64_t	st_size;	/* Size of object (e.g., common) */
 } E64Sym;
 
+
+typedef struct Sym {
+	int64_t	value;
+	char	*name;
+	uint8_t	binding;
+	uint8_t	symtype;
+	uint	sig;
+	char	type;
+} Sym;
+
 enum {
 	/* Ehdr codes */
 	MAG0 = 0,		/* ident[] indexes */
@@ -145,10 +155,10 @@ enum {
 	X = 0x1,
 
 	/* Shdr Codes */
-	Progbits = 1,		/* section types */
-	Symtab = 2,
-	Strtab = 3,
-	Nobits = 8,
+	SHT_PROGBITS = 1,	/* section types */
+	SHT_SYMTAB = 2,
+	SHT_STRTAB = 3,
+	SHT_NOBITS = 8,
 
 	Swrite = 1,		/* section attributes */
 	Salloc = 2,

+ 2 - 2
sys/include/mach.h

@@ -10,8 +10,8 @@
 /*
  *	Architecture-dependent application data
  */
-#include "a.out.h"
-//#include "elf.h"
+//#include "a.out.h"
+#include "elf.h"
 /*
  *	Supported architectures:
  *		mips,

+ 3 - 3
sys/src/libmach/executable.c

@@ -11,7 +11,7 @@
 #include	<libc.h>
 #include	<bio.h>
 #include	<mach.h>
-#include	"elf.h"
+//#include	"elf.h"
 
 /*
  *	All a.out header types.  The dummy entry allows canonical
@@ -257,12 +257,12 @@ elf64dotout(int fd, Fhdr *fp, ExecHdr *hp)
 
 	int isym = -1, istr = -1;
 	for (int i = 0; i < ep->shnum; i++) {
-		if (sh[i].type == Symtab && isym == -1) {
+		if (sh[i].type == SHT_SYMTAB && isym == -1) {
 			// Assume the first is the one we want for now
 			// There may be more than one if it's dynamic, but we
 			// don't support than, so hopefully this is ok for now
 			isym = i;
-		} else if (sh[i].type == Strtab && istr == -1) {
+		} else if (sh[i].type == SHT_STRTAB && istr == -1) {
 			// Assume first is the one we want for now, but we
 			// should probably check that the name is '.strtab' to
 			// distinguish from .shstrtab.

+ 1 - 1
sys/src/libmach/sym.c

@@ -11,7 +11,7 @@
 #include <libc.h>
 #include <bio.h>
 #include <mach.h>
-#include <elf.h>
+//#include <elf.h>
 
 #define	HUGEINT	0x7fffffff
 #define	NNAME	20		/* a relic of the past */