ref: 559a18680dd0c9fbb7683dc57a3e93b6eff5fe12
parent: 83313d4505acea160478ef7bf2c60645e3cec526
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Aug 23 14:33:01 EDT 2019
[libmach] Don't free obj in objdel() This makes easier to use objdel for strip, because it doesn't make sense to have relocation information in the generic part when we do not have taget information.
--- a/src/libmach/coff32/coff32del.c
+++ b/src/libmach/coff32/coff32del.c
@@ -20,4 +20,5 @@
obj->data = NULL;
objdel(obj);
+ free(obj);
}
--- a/src/libmach/coff32/coff32strip.c
+++ b/src/libmach/coff32/coff32strip.c
@@ -34,6 +34,7 @@
coff->ents = NULL;
coff->rels = NULL;
coff->lines = NULL;
+ objdel(obj);
return 0;
}
--- /dev/null
+++ b/src/libmach/objdel.c
@@ -1,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <scc/mach.h>
+
+#include "libmach.h"
+
+void
+objdel(Obj *obj)
+{
+ free(obj->secs);
+ free(obj->syms);
+
+ obj->syms = NULL;
+ obj->secs = NULL;
+ memset(obj->htab, 0, sizeof(obj->htab));
+}
--- a/src/libmach/objfree.c
+++ /dev/null
@@ -1,15 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <scc/mach.h>
-
-#include "libmach.h"
-
-void
-objdel(Obj *obj)
-{
- free(obj->secs);
- free(obj->syms);
- free(obj);
-}