diff options
Diffstat (limited to 'cooker/gluten.c')
-rw-r--r-- | cooker/gluten.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cooker/gluten.c b/cooker/gluten.c index 4d3aea5..69c9384 100644 --- a/cooker/gluten.c +++ b/cooker/gluten.c @@ -146,6 +146,7 @@ void gluten_add_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id, union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id) { + union value missing = { 0 }; int i; for (i = 0; i < ATTRS_MAX && g->attrs[i].type; i++) { @@ -153,8 +154,8 @@ union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, return g->attrs[i].v; } - die(" attribute '%p' not found", id); - return g->attrs[0].v; /* Pro forma, not actually happening */ + debug(" attribute '%p' not found", id); + return missing; } /** @@ -163,8 +164,8 @@ union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type, */ void gluten_init(struct gluten_ctx *g) { - g->ip.type = g->lr.type = g->mr.type = OFFSET_INSTRUCTION; g->ip.offset = g->lr.offset = g->mr.offset = 0; + g->ip.type = g->lr.type = g->mr.type = OFFSET_INSTRUCTION; g->dp.type = OFFSET_DATA; g->cp.type = OFFSET_RO_DATA; } @@ -185,3 +186,12 @@ void gluten_write(struct gluten_ctx *g, const char *path) close(fd); } + +void gluten_relocation_add(struct gluten_ctx *g, struct gluten_offset offset) +{ + g->g.header.relocation[g->rel_count++] = offset; + debug(" Added relocation for %s: %u", gluten_offset_name[offset.type], + offset.offset); + if (g->rel_count >= 256) + die("Too many relocations"); +} |