libbsd: Manipulating object files using waf build system

Christian Mauderer christian.mauderer at embedded-brains.de
Tue Aug 2 06:04:03 UTC 2016


Hello,

I have a second waf problem beneath the one already discussed in the
other thread: Is it possible to do some object file manipulation before
linking? To be exact I would need to rename some of the sections in the
object files.


If you want to stop reading, you can do it here. The following is only
some background Information why this is necessary:

Currently I'm porting the user space tool pfctl to set up the firewall
pf to libbsd. For all initialized (zero or value) global or static
variables I basically use the following method:

- put all variables into one named linker section
- save the section before calling the main
- restore the section after calling main

I'll add a more detailed description for the method that I used to port
into the libbsd.txt as soon as I'm finished with the work.


I have made some changes that I was trying to upstream to FreeBSD. The
changes are quite similar to the ones for other programs:

- Make const what can be const.
- Make global variables static if possible.
- Move some static variables out of function scope.

I've suggested these changes on the FreeBSD mailing list here:

https://lists.freebsd.org/pipermail/freebsd-hackers/2016-July/049772.html

The last one (moving the static variables out of the functions) was
necessary so I could easily add an attribute to the variables. Due to
the fact that it is not really an improvement, it has started some
discussion:

https://lists.freebsd.org/pipermail/freebsd-hackers/2016-August/049821.html

The method described there would not work for us. But we should be able
to rename some of the sections. Compared to my current method (adding an
attribute to every variable) this would make it simpler to update to a
newer version with some changed global variables. So it's worth a try.

Kind regards,

Christian Mauderer

-- 
--------------------------------------------
embedded brains GmbH
Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.mauderer at embedded-brains.de
Phone: +49-89-18 94 741 - 18
Fax:   +49-89-18 94 741 - 08
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


More information about the devel mailing list