tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: On upgrading elftoolchain in src/



Inline...

> On Mar 25, 2021, at 6:26 PM, jkoshy%netbsd.org@localhost wrote:
> 
> Upstream <libelf.h> uses elfdefinitions.h, as does the rest of the
> upstream toolchain (i.e. elfcopy, strings, size, strip, nm, etc).
> 
> LibELF-using programs (say in pkgsrc) that are being compiled on NetBSD
> would also end up using these symbols.

Ok, thanks!

> I plan to change upstream so that the file can be placed under <sys/>.

Great.

> Yes.
> 
> There is also a subtle portability issue with the way I am using
> enumerations which was brought to my attention, and which I intend to fix.
> 
> This is that the C standard defines enumerations as having a type of
> 'int'.  But some values within these enumerations could be larger than
> INT_MAX on some platforms, triggering implementation-dependent behavior on
> the part of the C compiler.  This may not matter in practice for CLang &
> GCC but I would prefer to be ISO C compliant to the extent possible.
> 
> So I plan to change the header to use plain '#define's.  The string
> constants will be moved somewhere else, say to libelftc (a helper library
> used by the rest of Elftoolchain code).

That's good. Enums have advantages (the debugger can print them symbolically
and you can type check and test for coverage in switches as long as they are named).
If they are unnamed, our lint complains (with Roland's latest changes), I am not sure
if gcc handles them properly... OTOH #defines can be checked for existence at compile
time...

> Noted.  Would this be a readability issue or a potential compilation
> speed issue?
> 
> If the latter it would be easy enough to wrap specific classes of symbols
> in #ifdef blocks if needed.

Not a speed issue; I was thinking that the header is getting too long and many
programs don't need some of the specific details (note definitions for example).
Or things needed by debuggers, or relocations...
But that's a minor issue...

> Agreed, more compatibility across the BSDs would be a good thing.

Agreed, having a standard header for elf definitions is a good thing!

Best,

christos

Attachment: signature.asc
Description: Message signed with OpenPGP



Home | Main Index | Thread Index | Old Index