[Mesa-dev] [PATCH 08/14] i965: Build the driver into a shared mesa_dri_drivers.so .

Emil Velikov emil.l.velikov at gmail.com
Tue Oct 1 13:00:23 PDT 2013


On 30/09/13 21:44, Eric Anholt wrote:
> Previously, we've split things such that mesa core is in libdricore,
> exposing the whole Mesa core interface in the global namespace, and the
> i965_dri.so code all links against that.  Along with polluting application
> namespace terribly, it requires extra PLT indirections and prevents LTO.
> 
> Instead, we can build all of the driver contents into the same .so with
> just a few symbols exposed to be referenced from the actual driver .so
> file, allowing LTO and reducing our exposed symbol count massively.
> ---
>  configure.ac                                  | 29 +++++++++++---
>  src/mesa/drivers/dri/Makefile.am              | 54 ++++++++++++++++++++++++++-
>  src/mesa/drivers/dri/common/Makefile.am       |  3 ++
>  src/mesa/drivers/dri/common/dri_util.c        | 10 +++--
>  src/mesa/drivers/dri/common/megadriver_stub.c | 41 ++++++++++++++++++++
>  src/mesa/drivers/dri/i965/Makefile.am         | 27 +++-----------
>  src/mesa/drivers/dri/i965/intel_screen.c      | 16 ++++++--
>  src/mesa/drivers/dri/i965/intel_screen.h      |  2 +
>  8 files changed, 147 insertions(+), 35 deletions(-)
>  create mode 100644 src/mesa/drivers/dri/common/megadriver_stub.c
> 
[...]
> diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
> index 9a99ea9..3126ac8 100644
> --- a/src/mesa/drivers/dri/common/dri_util.c
> +++ b/src/mesa/drivers/dri/common/dri_util.c
> @@ -106,10 +106,12 @@ dri2CreateNewScreen2(int scrn, int fd,
>      /* If the driver exposes its vtable through its extensions list
>       * (megadrivers), use that instead.
>       */
> -    for (int i = 0; driver_extensions[i]; i++) {
> -       if (strcmp(driver_extensions[i]->name, __DRI_DRIVER_VTABLE) == 0) {
> -          psp->driver =
> -             ((__DRIDriverVtableExtension *)driver_extensions[i])->vtable;
> +    if (driver_extensions) {
> +       for (int i = 0; driver_extensions[i]; i++) {
> +          if (strcmp(driver_extensions[i]->name, __DRI_DRIVER_VTABLE) == 0) {
> +             psp->driver =
> +                ((__DRIDriverVtableExtension *)driver_extensions[i])->vtable;
> +          }
>         }
>      }
>  
I believe this hunk would need to be squashed in previous patch.
Otherwise we'll fail with null ptr deref due to as driver_extensions is
NULL, when called from dri*CreateNewScreen() context.

Cheers
Emil


More information about the mesa-dev mailing list