commit 3c28376f3976488528e07c50e839326bf4b77605
parent c2df1b3d34545f2ef046aca375574aef7a6a932a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 18 Jan 2025 14:08:14 +0100
libmach: Make public type interfaces
The object type can be used in speciliazed tools to determine
some properties of the different object formats.
Diffstat:
3 files changed, 33 insertions(+), 45 deletions(-)
diff --git a/include/bits/scc/mach.h b/include/bits/scc/mach.h
@@ -1,3 +1,16 @@
+/*
+ * some systems define macros with this name even when
+ * they should be c99 compliant.
+ */
+#undef LITTLE_ENDIAN
+#undef BIG_ENDIAN
+
+#define NBYTES 32
+#define OBJ(format,arch,order) ((order) << 10 | (arch) << 5 | (format))
+#define FORMAT(t) ((t) & 0x1f)
+#define ARCH(t) (((t) >> 5) & 0x1f)
+#define ORDER(t) (((t) >> 10) & 0x1f)
+
typedef struct segment Segment;
typedef struct section Section;
typedef struct symbol Symbol;
@@ -6,6 +19,26 @@ typedef struct obj Obj;
typedef struct map Map;
typedef struct mapsec Mapsec;
+enum objformat {
+ COFF32,
+ ELF64,
+ NFORMATS,
+};
+
+enum objarch {
+ ARCH286,
+ ARCH386,
+ ARCHAMD64,
+ ARCHZ80,
+ ARCHARM32,
+ ARCHARM64,
+};
+
+enum order {
+ LITTLE_ENDIAN,
+ BIG_ENDIAN,
+};
+
/**
* enum sectype - Section property flags
* @SREAD: The segment has read rights
diff --git a/src/cmd/scc-as/as.h b/src/cmd/scc-as/as.h
@@ -13,18 +13,6 @@ enum symflags {
FABS = 1 << 7,
};
-/*
- * some systems polute the namespace defining BIG_ENDIAN and
- * LITTLE_ENDIAN
- */
-#undef BIG_ENDIAN
-#undef LITTLE_ENDIAN
-
-enum endianess {
- BIG_ENDIAN = -1,
- LITTLE_ENDIAN = 1
-};
-
enum common_args {
AIMM = 1,
ASTR,
diff --git a/src/libmach/libmach.h b/src/libmach/libmach.h
@@ -1,36 +1,3 @@
-/*
- * some systems define macros with this name even when
- * they should be c99 compliant.
- */
-#undef LITTLE_ENDIAN
-#undef BIG_ENDIAN
-
-#define NBYTES 32
-#define OBJ(format,arch,order) ((order) << 10 | (arch) << 5 | (format))
-#define FORMAT(t) ((t) & 0x1f)
-#define ARCH(t) (((t) >> 5) & 0x1f)
-#define ORDER(t) (((t) >> 10) & 0x1f)
-
-
-enum objformat {
- COFF32,
- ELF64,
- NFORMATS,
-};
-
-enum objarch {
- ARCH286,
- ARCH386,
- ARCHAMD64,
- ARCHZ80,
- ARCHARM32,
- ARCHARM64,
-};
-
-enum order {
- LITTLE_ENDIAN,
- BIG_ENDIAN,
-};
struct objops {
int (*type)(char *);