summaryrefslogtreecommitdiff
path: root/hw/xfree86/loader/loadmod.c
AgeCommit message (Collapse)AuthorFilesLines
2017-10-30Use ARRAY_SIZE all over the treeDaniel Martin1-1/+2
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with the ARRAY_SIZE macro from dix.h when possible. A semantic patch for coccinelle has been used first. Additionally, a few macros have been inlined as they had only one or two users. Signed-off-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-04-26Use #ifdef instead of #if for features to make Meson easier.Eric Anholt1-2/+2
We mostly use #ifdef throughout the tree, and this lets the generated config.h files just be #define TOKEN instead of #define TOKEN 1. Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net>
2017-02-01loader: Handle mod->VersionInfo == NULLMichel Dänzer1-10/+11
This can happen when a module fails to load: Program received signal SIGSEGV, Segmentation fault. UnloadModule (_mod=0x5555559d9280) at ../../../../hw/xfree86/loader/loadmod.c:848 848 name = mod->VersionInfo->modname; (gdb) bt #0 UnloadModule (_mod=0x5555559d9280) at ../../../../hw/xfree86/loader/loadmod.c:848 #1 0x00005555555ddd1b in LoadModule (module=module@entry=0x5555559c7ce0 "fbdev", options=0x0, modreq=modreq@entry=0x0, errmaj=errmaj@entry=0x7fffffffe8ec) at ../../../../hw/xfree86/loader/loadmod.c:824 #2 0x00005555555edfe9 in xf86LoadModules (list=list@entry=0x5555559dcf50, optlist=optlist@entry=0x0) at ../../../../hw/xfree86/common/xf86Init.c:1506 #3 0x00005555555ee7bc in InitOutput (pScreenInfo=pScreenInfo@entry=0x5555559abf80 <screenInfo>, argc=argc@entry=4, argv=argv@entry=0x7fffffffeb18) at ../../../../hw/xfree86/common/xf86Init.c:484 #4 0x00005555555a885c in dix_main (argc=4, argv=0x7fffffffeb18, envp=<optimized out>) at ../../dix/main.c:197 #5 0x00007ffff5d582b1 in __libc_start_main (main=0x555555593130 <main>, argc=4, argv=0x7fffffffeb18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffeb08) at ../csu/libc-start.c:291 #6 0x000055555559316a in _start () Fixes: 8e83eacb9e2d ("loader: Remove unused path and name from ModuleDescPtr") Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-01-25loader: Learn about the joy of snprintfAdam Jackson1-9/+2
Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Remove unused path and name from ModuleDescPtrAdam Jackson1-22/+9
Just a waste of memory. Path was never referenced at all, and name was only used when unloading the module; we can just as well get the module's internal idea of its name from VersionInfo. Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Remove unused arguments from LoadModuleAdam Jackson1-139/+10
Nobody was ever calling this with a non-null argument for subdir list or pattern list. Having done this, InitSubdirs is only ever called with a NULL argument, so it's really just a complicated way of duplicating the default list; we can remove that and just walk the list directly. The minor error code was only ever used to distinguish among two cases of LDR_BADUSAGE. Whatever. Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Turn LoaderListDirs into LoaderListDirAdam Jackson1-57/+42
Callers only ever use this for a single directory anyway. While we're at it, also move xf86DriverListFromCompile near its only user in the X -configure code (and inline it out of existence), and remove LoaderFreeDirList as it's unused (since X -configure is just going to exit anyway, none of that code cares about cleanup). Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Remove silly "unspecified" version handlingAdam Jackson1-28/+19
Everybody using this functionality specifies a major version, which makes sense. If you don't care about a minor version, that's equivalent to saying you require minor >= 0, so just say so; likewise patch level. Likewise ABI class is always specified. Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Remove unused loader error codes and dead enumAdam Jackson1-18/+0
The enum has been unused since at least the removal of elfloader. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Don't add internal/ to the search pathAdam Jackson1-1/+0
Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Remove *GetOSAdam Jackson1-13/+1
This API is dumb. uname(3) exists, feel free to use it, but ideally write to the interface not to the OS. There are a couple of drivers using this API, they could all reasonably just not. This also removes the OS name from the loader subdirectory path search. Having /usr/lib/xorg shared across OSes is a non-goal here. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25loader: Port from xfree86 to dix APIAdam Jackson1-76/+65
Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2017-01-25xfree86: flatten pathlist management in the loaderEmil Velikov1-14/+2
Now that users can set the path only via LoaderSetPath(), we can simplify things. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-01-25xfree86: remove unused path from the LoadModule APIEmil Velikov1-4/+3
Similar to its little brother - LoadSubModule. Currently all call sites provide NULL anyway ;-) Reviewed-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2016-12-14xfree86: Add ModulePath support for OutputClass config SectionsHans De Goede1-0/+1
Allow OutputClass config snippets to modify the module-path. Note that any specified ModulePaths will be pre-pended to the normal ModulePath. The idea behind this is that any output hardware specific modules should have preference over the normal modules. One use-case for this is the nvidia binary driver, this allows a config snippet like this: Section "OutputClass" MatchDriver "nvidia" Modulepath "/usr/lib64/nvidia/modules" EndSection To get the nvidia glx specific glx module loaded, but only when the nvidia kernel driver is loaded. Together with the glvnd work done recently, this allows the nouveau + mesa and nvidia-binary userspace stacks to co-exist on the same system without any ldconfig / xorg.conf tweaking and the xserver will automatically do the right thing depending on which kernel driver (nouveau or nvidia) is loaded. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-08-24xfree86: print the module name together with the load failure messagePeter Hutterer1-16/+19
We're happily printing the error to stdout but not which module caused it... That's in the Xorg.log but that's at least one click away. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-03-14xfree86: Finish removing font modulesAdam Jackson1-3/+0
Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-04-21Convert hw/xfree86 to new *allocarray functionsAlan Coopersmith1-5/+5
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
2014-11-12Drop trailing whitespacesPeter Hutterer1-2/+2
sed -i "s/[ ]\+$//g" **/*.(c|h) happy reviewing... git diff -w is an empty diff. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-10-08loader: Remove some baklava codeAdam Jackson1-65/+48
Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-09-18loader: Remove compatibility with ancient XFree86 version numberingAdam Jackson1-37/+9
Pretty sure I'm guilty of adding this. I think I was thinking of trying to be compatible with some really old binary-only driver that I had vague aspirations of reverse-engineering, but since I haven't gotten around to it in the intervening decade... Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2014-07-24xfree86: Remove i2c multimedia modulesAdam Jackson1-1/+0
These came in with the GATOS merge I think. The only driver using them was radeon, and then only in UMS mode. The radeon driver dropped UMS support from the main branch about two years ago, the UMS branch hasn't been touched in about fifteen months, and does not build against 1.16 in any case, so this is all dead code. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2014-06-02xfree86: Report Present as a built-in moduleChris Wilson1-0/+3
This is so that drivers can do a runtime check that Present is available, similar to existing runtime checks performed by the drivers for DRI. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Keith Packard <keithp@keithp.com>
2014-06-02xfree86: Report DRI3 as a built-in moduleChris Wilson1-0/+3
This is so that drivers can do a runtime check that DRI3 is available, similar to existing runtime checks performed by the drivers for DRI and DRI2. v2: Only add DRI3 to the list if the module was actually built into the server (Mark Kettenis). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mark Kettenis <mark.kettenis@xs4all.nl> Signed-off-by: Keith Packard <keithp@keithp.com>
2014-01-12Replace 'pointer' type with 'void *'Keith Packard1-8/+8
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer' is used throughout the X server for other things, and having duplicate names generates compiler warnings. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12xfree86/common: Warning fixes. Mostly const string handling.Keith Packard1-3/+3
Also removes DPMS functiosn from Xext/dpmsproc.h Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2012-07-10Move DRI2 from external module to built-inDaniel Stone1-0/+1
Instead of keeping a tiny amount of code in an external module, just man up and build it into the core server. v2: Fix test/Makefile.am to only link libdri2.la if DRI2 is set Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-10Move DRI1 from external module to built-inDaniel Stone1-0/+1
Rather than building the tiny amount of code required for XFree86-DRI as an external module, build it in if it's enabled at configure time. v2: Fix test/Makefile.am to only link libdri.la if DRI is set Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com> fixup for DRI1 move Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-10Remove the last remnants of extmodDaniel Stone1-0/+1
extmod was originally a big pointless module. Now it's an empty, pointless module. This commit makes it unexist. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Move RECORD from external module to built-inTomas Carnecky1-0/+1
Rather than languishing in its own special module, move RECORD into the core server. Signed-off-by: Tomas Carnecky <tom@dbservice.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Move DBE from an external module to built-inTomas Carnecky1-0/+1
If DBE support is compiled in the server, just man up and build it into the server, rather than having it as an external module. Signed-off-by: Tomas Carnecky <tom@dbservice.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Jamey Sharp <jamey@minilop.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09Loader: Drop EXTERN_MODULE flagDaniel Stone1-4/+0
EXTERN_MODULE was used to specify that we shouldn't worry about modules lacking a ModuleData object. It was also completely unused. *shrug* Signed-off-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-04Look for ModuleData only in appropriate libraryMichal Srb1-1/+1
LoaderSymbol calls dlsym with RTLD_DEFAULT pseudo handle making it search in every loaded library. In addition glibc adds NODELETE flag to the library containing the symbol. It's used in doLoadModule to locate <modulename>ModuleData symbol, the module's library gets the flag and is kept in memory even after it is unloaded. This patch adds LoaderSymbolFromModule function that looks for symbol only in library specified by handle. That way the NODELETE flag isn't added. This glibc behavior doesn't seem to be documented, but even if other implementations differ, there is no reason to search ModuleData symbol outside the module's library. Signed-off-by: Michal Srb <msrb@suse.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> v2: Switch LoaderSymbolFromModule arguments order. Correct description. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-07-02Log in UnloadModuleOrDriver() in a signal safe mannerChase Douglas1-2/+3
The function may be called from a fatal signal handler. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-04-05loader: add Cygwin supportYaakov Selkowitz1-0/+18
Cygwin libraries use the .dll extension and "cyg" prefix in place of "lib". Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2012-03-21Introduce a consistent coding styleKeith Packard1-544/+553
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-01-09UnloadSubModule(): accept pointer value '1' and ignore it.Matthieu Herrb1-0/+3
Some driver modules try to unload submodules that are now built-in. Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-05LoaderOpen returns either a valid pointer or NULL, so don't check for < 0Alan Coopersmith1-1/+1
Fixes Sun cc warning that was recently elevated to error by the stricter default CFLAGS changes to xorg-macros: "loadmod.c", line 914: improper pointer/integer combination: op "<" Should have been changed when commit ab7f057ce9df4e905b12 changed the LoaderOpen return type from int to void *. Changes log message when file is found but dlopen() fails from: (EE) LoadModule: Module dbe does not have a dbeModuleData data object. (EE) Failed to load module "dbe" (invalid module, 0) to: (EE) Failed to load module "dbe" (loader failed, 7) Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2011-11-23FindModule: stop copying const char *dirname to char *dirpathAlan Coopersmith1-8/+3
Not needed since 6cf844ab69926b split out the allocation/manipulation into the helper function, leaving FindModule just copying the pointer around, and causing gcc warnings and an unreachable call to free. Also no longer need to store the combined strlen results in dirlen. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-10-18Do not uselessly reload modules in DuplicateModuleMichal Suchanek1-9/+9
The function does not initialize the module so it has no business loading it. If some user of DuplicateModule expects a module actually loaded they should use LoadModule. Signed-off-by: Michal Suchanek <hramrach@centrum.cz> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-10-18Use UnloadModuleOrDriver for UnloadSubModule.Michal Suchanek1-17/+6
Signed-off-by: Michal Suchanek <hramrach@centrum.cz> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-04-07xfree86: loader: use one exit code only for readabilityTiago Vignatti1-20/+12
No functional changes. Spaghetti code for the win! \o/ Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org>
2011-04-04xfree86: loader: fix memory leaks in LoaderListDirsTiago Vignatti1-0/+6
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-12-31loader: warning fixAdam Jackson1-1/+1
loadmod.c: In function ‘FreeSubdirs’: loadmod.c:377: warning: passing argument 1 of ‘free’ discards qualifiers from pointer target type /usr/include/stdlib.h:488: note: expected ‘void *’ but argument is of type ‘const char *’ Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-12-07Replace alloc+strcpy+strcat with asprintf() & XNFasprintf() callsAlan Coopersmith1-4/+2
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-12-07Convert alloc+sprintf pairs into asprintf() & XNFasprintf() callsAlan Coopersmith1-6/+6
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2010-11-30FindModuleInSubdir: Stop allocating one more byte than neededAlan Coopersmith1-3/+3
15ac25627e7239629be59 removed the "/" from the sprintf strings, but failed to remove the extra byte allocated for the '/'. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Julien Cristau <jcristau@debian.org>
2010-09-22loader: Remove a silly layer of reference countingAdam Jackson1-42/+36
libdl will refcount objects for us just fine, thanks. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-09-22loader: Remove the handle field from LoaderOpenAdam Jackson1-1/+1
This was always 0 from all the callers. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-09-22loader: Remove unused canonical name fieldAdam Jackson1-2/+1
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>