Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Aug 2016 07:36:36 +0200
From:      Christian Mauderer <christian.mauderer@embedded-brains.de>
To:        Kristof Provost <kp@FreeBSD.org>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: Changes to pfctl to allow easier integration into a library
Message-ID:  <336150f6-9dcd-873f-1f8f-a264dfa4c4ed@embedded-brains.de>
In-Reply-To: <B5DEAF43-9CBD-4C74-AE71-8B7FD278BAA8@FreeBSD.org>
References:  <25df9fd5-be75-b9ae-aa3a-22abef3bddf0@embedded-brains.de> <cb7c6bb6-8160-3524-5432-d4ff46e16af5@embedded-brains.de> <0C7EC45D-C3BC-4417-AF77-3ACC027D28B5@FreeBSD.org> <a2479a3c-031c-c137-78a9-8a8f34a12100@embedded-brains.de> <B5DEAF43-9CBD-4C74-AE71-8B7FD278BAA8@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help


Am 01.08.2016 um 20:36 schrieb Kristof Provost:
> On 1 Aug 2016, at 16:32, Christian Mauderer wrote:
>=20
>     Am 01.08.2016 um 16:02 schrieb Kristof Provost:
>=20
>         On 1 Aug 2016, at 15:03, Christian Mauderer wrote:
>=20
>             Can I improve anything to make the patches more acceptable?
>=20
>         Can you explain why
>         0003-pfctl-Pull-static-variables-out-of-the-function.patch is
>         required?
>         I=E2=80=99m not sure I see why you need it.
>=20
>     I use roughly the following method for the global variables:
>     - I put all initialized (zero or value) variables into a special na=
med
>     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 differenc=
e
>     between the sources we use and the original FreeBSD sources should =
be
>     minimal. Therefore my attempt to put the variables into a section i=
s
>     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 i=
s
>     included at the end of the original pfctl.c.
>=20
> Oh.
> Ick.
> Clever, but =E2=80=A6 ick.
>=20
> I=E2=80=99m not a big fan of this patch, because it makes the code a bi=
t harder
> to follow, rather than improving things as most of your other patches d=
o.
> I suspect that something similar can be accomplished with a bit of
> linker trickery.
>=20
> A first idea is to insert two new symbols (e.g. pf_begin/pf_end) in two
> separate files, the first before all of the pfctl object files, the
> second after them.
> This should let you group the .data section of the pfctl globals,
> accomplishing what you do here with the *attribute* attribute.
>=20
> Regards,
> Kristof
>=20

Hello Kristof,

I agree that my solution is not optimal and that this specific patch
does not really improve the code for you. So I'll try to find alternative=
s.

The method you suggested would not work for us. We are using part of the
FreeBSD sources as a library that is statically linked with the rest of
the system. Using our build process, the order of the object files does
not guarantee an order of the symbols. As far as I know a fixed order
can only be achieved by the section names.

Theoretically it could be possible to get a similar result with some
object file manipulation (renaming sections, ...). I'll check if I'm
able to use such a solution instead and report back as soon as I can
tell you more.

Kind regards,

Christian Mauderer

--=20
--------------------------------------------
embedded brains GmbH
Christian Mauderer
Dornierstr. 4
D-82178 Puchheim
Germany
email: christian.mauderer@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=C3=A4ftliche Mitteilung im Sinne des EHUG=
.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?336150f6-9dcd-873f-1f8f-a264dfa4c4ed>