scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 64e796d7f793a5f8dc05855cf1d534fa60935939
parent 445f2cdc2c531499b5e0b4388075c6af49396540
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 11 Feb 2019 16:56:39 +0000

[ld] Store section description from object files

Diffstat:
Msrc/cmd/ld.c | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/cmd/ld.c b/src/cmd/ld.c @@ -30,6 +30,8 @@ enum { struct objlst { Obj *obj; + int nsect; + Objsect *sect; struct objlst *next; }; @@ -195,15 +197,24 @@ newsym(Objsym *osym, void *obj) static void loadobj(Obj *obj) { + int n; Objlst *lst; + Objsect *secp; if ((lst = malloc(sizeof(*lst))) == NULL) { error("out of memory"); return; } + if ((n = objsect(obj, &secp)) < 0) { + error("out of memory"); + goto err1; + } + lst->obj = obj; lst->next = NULL; + lst->nsect = n; + lst->sect = secp; if (!objlast) objlast = objhead = lst; @@ -211,6 +222,11 @@ loadobj(Obj *obj) objlast = objlast->next = lst; forsym(obj, newsym, obj); + + return; + +err1: + free(lst); } static void