Defns have to do: int internal_function foo (...) i386 build will break with internal_function decls but not defns.
s/dwarf_readhooks.c/libdw_relocate.c/ A dwarf_*.c name is for a file implementing a function of that name.
All the calls seem to use a size == 8 expression for the bool argument. Just make it an offset/address size argument that is 4/8.
s/addr/off/ in dwarf_formref_die, dwarf_getpubnames
+ Dwarf_Addr escape = addr64 ? (Elf64_Addr)-1 : (Elf64_Addr)(Elf32_Addr)-1; Write a libdwP.h macro for this (taking address_size rather than bool). It will be used again in dwarf_ranges.
s/Dwarf_Word/Dwarf_Off/ for offset-flavored parameters. s/Dwarf_Word/Dwarf_Addr/ for address-flavored parameters.
I don't think the names are too long. Let's use "address" and "offset". If it makes the decoder code nicer, define macros or static inlines "read_address" and "read_offset" (+"_inc") wrappers for convenience. (You might want to do that for the _inc flavors anyway, so the arithmetic inlines away.)
Make read_offset also take an IDX_* argument for the referring section. If it's a macro, you can make the args short and use IDX_debug_##arg.
+ if (*offset >= data->d_size + || *offset + addr64 ? 8 : 4 >= data->d_size) Use: || data->d_size - offset_size < *offset)
Don't call the addr function in the off function. Even as soon as the test code, they will be disjoint code paths. (A common local inline that has the size-check if clause and zero extension is fine of course.)
Use const pointers everywhere.
Two of these: + return -1l; Neither of those functions return long int. Use plain -1.
Thanks, Roland
Make read_offset also take an IDX_* argument for the referring section. If it's a macro, you can make the args short and use IDX_debug_##arg.
read_offset and read_address both need this. They need to know what section the reference comes from. In the test kludge phase they will just emit that in their messages to match up with what dwarflint is looking for. In the real smart reader implementation, they need this index to look up which relocation section they are handling.
Thanks, Roland
Use const pointers everywhere.
That was the original plan, but you can't assign char** to char const** under C typing. I decided it's better to just keep them char** to avoid having to either type cast the pointers in function arguments, or having to rewrite surrounding typing.
Two of these:
return -1l;
Neither of those functions return long int. Use plain -1.
The one in dwarf_getpubnames is there because other return statements do that, too, in the same function. The function returns ptrdiff_t -- that does have a size of long, doesn't it?
PM
Use const pointers everywhere.
That was the original plan, but you can't assign char** to char const** under C typing. I decided it's better to just keep them char** to avoid having to either type cast the pointers in function arguments, or having to rewrite surrounding typing.
Oh, char ** for result params of *_inc is OK. But there are others IIRC.
The one in dwarf_getpubnames is there because other return statements do that, too, in the same function. The function returns ptrdiff_t -- that does have a size of long, doesn't it?
Ah, yes, it does. Ok. (It really doesn't hurt to use -1 there either, though.)
Thanks, Rooland
elfutils-devel@lists.fedorahosted.org