Changes to pfctl to allow easier integration into a library
Christian Mauderer
christian.mauderer at embedded-brains.de
Mon Aug 1 14:32:50 UTC 2016
Am 01.08.2016 um 16:02 schrieb Kristof Provost:
> On 1 Aug 2016, at 15:03, Christian Mauderer wrote:
>> Can I improve anything to make the patches more acceptable?
>>
> Can you explain why
> 0003-pfctl-Pull-static-variables-out-of-the-function.patch is required?
> I’m not sure I see why you need it.
>
>> Is the virtualisation that Bjoern mentioned necessary or was my
>> interpretation correct that this is only meant for kernel space code?
> I believe your interpretations is correct.
> User land code should not have to care about VIMAGE.
>
> Regards,
> Kristof
Hello Kristof,
I use roughly the following method for the global variables:
- I put all initialized (zero or value) variables into a special named
linker section.
- In a wrapper around main() I do the following:
o First save the content of the section to a temporary memory space
o Execute the original (mostly unchanged) main()
o After main() finishes, I restore the content of the section
To simplify a later update to a newer source version, the difference
between the sources we use and the original FreeBSD sources should be
minimal. Therefore my attempt to put the variables into a section is the
following:
I create a header file (i.e. pfctl-data.h) that contains a matching
declaration of the global variables but with an added gcc attribute
__attribute__((__section__("my_section_name"))). This header file is
included at the end of the original pfctl.c.
Problem is: This method doesn't work for a static variable that is
defined inside a function. Therefore I pulled them out of the functions
and put them into the scope of the c module.
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 freebsd-hackers
mailing list