commit b66f5506b858ae66635d27988ee9d4dd7e0471e6
parent 7b4fef3358a0397fe10577d0b0ce55399953ab7d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 19 Feb 2025 17:23:54 +0100
libmach: Remove Segment data type
The difference between segments and sections
was mainly for elf, which differentiatels between
them, but the attributes from the abstraction point
of view are the same, so we can use only one data
structure but different functions.
As the linker does not merge any sections yet,
we can just comment out the merge function
and nothing changes.
Diffstat:
4 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/include/bits/scc/mach.h b/include/bits/scc/mach.h
@@ -12,7 +12,6 @@
#define ORDER(t) (((t) >> 10) & 0x1f)
#define objfmt(o) FORMAT((o)->type)
-typedef struct segment Segment;
typedef struct section Section;
typedef struct symbol Symbol;
typedef struct obj Obj;
@@ -80,18 +79,6 @@ struct obj {
Obj *next;
};
-struct segment {
- char *name;
- unsigned long long base;
- unsigned long long size;
- unsigned flags;
- int index;
- int type;
- int align;
- int nsec;
- Section **sections;
-};
-
struct section {
char *name;
unsigned long long base;
diff --git a/src/cmd/scc-ld/ld.h b/src/cmd/scc-ld/ld.h
@@ -21,7 +21,7 @@ extern void debugsym(void);
extern Section *lookupsec(char *name);
extern void copy(Obj *obj, Section *osec, Section *sec);
extern void grow(Section *sec, int nbytes);
-extern void merge(Segment *seg);
+extern void merge(Section *seg);
extern void debugsec(void);
/* globals */
@@ -35,4 +35,4 @@ extern int dflag;
extern int gflag;
extern char *output, *entry;
extern Obj *objhead;
-extern Segment debug, text, rodata, data, bss;
+extern Section debug, text, rodata, data, bss;
diff --git a/src/cmd/scc-ld/main.c b/src/cmd/scc-ld/main.c
@@ -20,11 +20,11 @@ int nmagic; /* nmagic output */
char *filename, *membname;
-Segment text = {.type = 'T'};
-Segment rodata = {.type = 'R'};
-Segment data = {.type = 'D'};
-Segment bss = {.type = 'B'};
-Segment debug = {.type = 'N'};
+Section text = {.type = 'T'};
+Section rodata = {.type = 'R'};
+Section data = {.type = 'D'};
+Section bss = {.type = 'B'};
+Section debug = {.type = 'N'};
char *libpaths[MAX_LIB_PATHS];
diff --git a/src/cmd/scc-ld/section.c b/src/cmd/scc-ld/section.c
@@ -67,8 +67,9 @@ lookupsec(char *name)
}
void
-merge(Segment *seg)
+merge(Section *seg)
{
+#if 0
struct sectab *sp;
Section *sec, **p;
int n = 0;
@@ -90,6 +91,7 @@ merge(Segment *seg)
}
seg->nsec = n;
+#endif
}
static FILE *