Skip to content

Commit 6510b35

Browse files
committed
dw2elf: fix compilation errors — add dwarf.h, fix AT_name_a arg count
- Add #include <dwarf.h> to get DW_TAG_compile_unit, DW_TAG_subprogram, DW_TAG_formal_parameter constants (not exported via libdwarfp.h alone) - Fix all dwarf_add_AT_name_a() calls: signature requires 4 args (die, name, Dwarf_P_Attribute *outattr, Dwarf_Error *error) not 3 https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
1 parent 54d2b50 commit 6510b35

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

sys/src/ape/cmd/dw2elf/dw2elf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <sys/stat.h>
3131

3232
#include <libdwarf.h>
33+
#include <dwarf.h>
3334
#include <libdwarfp.h>
3435

3536
/* ── Plan9 a.out constants (amd64 fat header) ─────────────────────────── */
@@ -272,6 +273,7 @@ static void emit_sidecar(Dwarf_P_Debug dbg, const char *srcname,
272273
const uint8_t *buf, size_t len)
273274
{
274275
Dwarf_P_Die cu_die, func_die, param_die;
276+
Dwarf_P_Attribute attr_out;
275277
Dwarf_Error err;
276278
uint32_t nparams, nlocals, i, j;
277279
char *fname, *pname;
@@ -283,7 +285,7 @@ static void emit_sidecar(Dwarf_P_Debug dbg, const char *srcname,
283285
if(dwarf_new_die_a(dbg, DW_TAG_compile_unit,
284286
NULL, NULL, NULL, NULL, &cu_die, &err) != DW_DLV_OK)
285287
return;
286-
dwarf_add_AT_name_a(cu_die, (char *)srcname, &err);
288+
dwarf_add_AT_name_a(cu_die, (char *)srcname, &attr_out, &err);
287289
if(dwarf_add_die_to_debug_a(dbg, cu_die, &err) != DW_DLV_OK)
288290
return;
289291

@@ -296,7 +298,7 @@ static void emit_sidecar(Dwarf_P_Debug dbg, const char *srcname,
296298
if(dwarf_new_die_a(dbg, DW_TAG_subprogram,
297299
cu_die, NULL, NULL, NULL,
298300
&func_die, &err) == DW_DLV_OK)
299-
dwarf_add_AT_name_a(func_die, fname, &err);
301+
dwarf_add_AT_name_a(func_die, fname, &attr_out, &err);
300302

301303
for(i = 0; i < nparams; i++) {
302304
pname = sc_str();
@@ -305,7 +307,7 @@ static void emit_sidecar(Dwarf_P_Debug dbg, const char *srcname,
305307
if(dwarf_new_die_a(dbg, DW_TAG_formal_parameter,
306308
func_die, NULL, NULL, NULL,
307309
&param_die, &err) == DW_DLV_OK)
308-
dwarf_add_AT_name_a(param_die, pname, &err);
310+
dwarf_add_AT_name_a(param_die, pname, &attr_out, &err);
309311
}
310312
free(pname);
311313
}

0 commit comments

Comments
 (0)