Pay attention to the environment variable "LD_IGNORE_MISSING_OBJECTS".
If it is set to a nonempty string, then simply skip any missing shared libraries. This came up in a discussion long ago as a potentially useful feature at sysinstall time. For example, an X11 utility could be used without the X libraries being present, provided the utility had a mode in which no X functions were actually called.
This commit is contained in:
parent
c7e54a6a04
commit
ac6c268b3d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=21819
@ -106,7 +106,7 @@ library-name, major-version-number, minor-version-number
|
|||||||
recognises a number of environment variables that can be used to modify
|
recognises a number of environment variables that can be used to modify
|
||||||
its behaviour as follows:
|
its behaviour as follows:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width "LD_TRACE_LOADED_OBJECTS_PROGNAME"
|
.Bl -tag -width "LD_IGNORE_MISSING_OBJECTS"
|
||||||
.It Ev LD_LIBRARY_PATH
|
.It Ev LD_LIBRARY_PATH
|
||||||
A colon separated list of directories, overriding the default search path
|
A colon separated list of directories, overriding the default search path
|
||||||
for shared libraries.
|
for shared libraries.
|
||||||
@ -134,6 +134,30 @@ object. This is usually indicative of an incorrectly built library.
|
|||||||
When set to a nonempty string, no warning messages of any kind are
|
When set to a nonempty string, no warning messages of any kind are
|
||||||
issued. Normally, a warning is given if satisfactorily versioned
|
issued. Normally, a warning is given if satisfactorily versioned
|
||||||
library could not be found.
|
library could not be found.
|
||||||
|
.It Ev LD_IGNORE_MISSING_OBJECTS
|
||||||
|
When set to a nonempty string, makes it a nonfatal condition if
|
||||||
|
one or more required shared objects cannot be loaded.
|
||||||
|
Loading and execution proceeds using the objects that are
|
||||||
|
available.
|
||||||
|
A warning is produced for each missing object, unless the environment
|
||||||
|
variable
|
||||||
|
.Ev LD_SUPPRESS_WARNINGS
|
||||||
|
is set to a nonempty string.
|
||||||
|
.Pp
|
||||||
|
This is ignored for set-user-ID and set-group-ID programs.
|
||||||
|
.Pp
|
||||||
|
Missing shared objects can be ignored without errors if all the
|
||||||
|
following conditions hold:
|
||||||
|
.Bl -bullet
|
||||||
|
.It
|
||||||
|
They do not supply definitions for any required data symbols.
|
||||||
|
.It
|
||||||
|
No functions defined by them are called during program execution.
|
||||||
|
.It
|
||||||
|
The environment variable
|
||||||
|
.Ev LD_BIND_NOW
|
||||||
|
is unset or is set to the empty string.
|
||||||
|
.El
|
||||||
.It Ev LD_TRACE_LOADED_OBJECTS
|
.It Ev LD_TRACE_LOADED_OBJECTS
|
||||||
When set to a nonempty string, causes
|
When set to a nonempty string, causes
|
||||||
.Nm
|
.Nm
|
||||||
|
@ -188,6 +188,7 @@ static int careful;
|
|||||||
static int anon_fd = -1;
|
static int anon_fd = -1;
|
||||||
|
|
||||||
static char *ld_bind_now;
|
static char *ld_bind_now;
|
||||||
|
static char *ld_ignore_missing_objects;
|
||||||
static char *ld_library_path;
|
static char *ld_library_path;
|
||||||
static char *ld_preload;
|
static char *ld_preload;
|
||||||
static char *ld_tracing;
|
static char *ld_tracing;
|
||||||
@ -869,6 +870,15 @@ map_sods(parent)
|
|||||||
* "not found" message.
|
* "not found" message.
|
||||||
*/
|
*/
|
||||||
(void)alloc_link_map(NULL, sodp, parent, 0, 0);
|
(void)alloc_link_map(NULL, sodp, parent, 0, 0);
|
||||||
|
} else if (ld_ignore_missing_objects) {
|
||||||
|
char *msg;
|
||||||
|
/*
|
||||||
|
* Call __dlerror() even it we're not going to use
|
||||||
|
* the message, in order to clear the saved message.
|
||||||
|
*/
|
||||||
|
msg = __dlerror(); /* Should never be NULL */
|
||||||
|
if (!ld_suppress_warnings)
|
||||||
|
warnx("warning: %s", msg);
|
||||||
} else /* Give up */
|
} else /* Give up */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2022,6 +2032,7 @@ struct env_scan_tab {
|
|||||||
} scan_tab[] = {
|
} scan_tab[] = {
|
||||||
L("LD_LIBRARY_PATH=", 1, &ld_library_path)
|
L("LD_LIBRARY_PATH=", 1, &ld_library_path)
|
||||||
L("LD_PRELOAD=", 1, &ld_preload)
|
L("LD_PRELOAD=", 1, &ld_preload)
|
||||||
|
L("LD_IGNORE_MISSING_OBJECTS=", 1, &ld_ignore_missing_objects)
|
||||||
L("LD_TRACE_LOADED_OBJECTS=", 0, &ld_tracing)
|
L("LD_TRACE_LOADED_OBJECTS=", 0, &ld_tracing)
|
||||||
L("LD_BIND_NOW=", 0, &ld_bind_now)
|
L("LD_BIND_NOW=", 0, &ld_bind_now)
|
||||||
L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
|
L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
|
||||||
|
@ -106,7 +106,7 @@ library-name, major-version-number, minor-version-number
|
|||||||
recognises a number of environment variables that can be used to modify
|
recognises a number of environment variables that can be used to modify
|
||||||
its behaviour as follows:
|
its behaviour as follows:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width "LD_TRACE_LOADED_OBJECTS_PROGNAME"
|
.Bl -tag -width "LD_IGNORE_MISSING_OBJECTS"
|
||||||
.It Ev LD_LIBRARY_PATH
|
.It Ev LD_LIBRARY_PATH
|
||||||
A colon separated list of directories, overriding the default search path
|
A colon separated list of directories, overriding the default search path
|
||||||
for shared libraries.
|
for shared libraries.
|
||||||
@ -134,6 +134,30 @@ object. This is usually indicative of an incorrectly built library.
|
|||||||
When set to a nonempty string, no warning messages of any kind are
|
When set to a nonempty string, no warning messages of any kind are
|
||||||
issued. Normally, a warning is given if satisfactorily versioned
|
issued. Normally, a warning is given if satisfactorily versioned
|
||||||
library could not be found.
|
library could not be found.
|
||||||
|
.It Ev LD_IGNORE_MISSING_OBJECTS
|
||||||
|
When set to a nonempty string, makes it a nonfatal condition if
|
||||||
|
one or more required shared objects cannot be loaded.
|
||||||
|
Loading and execution proceeds using the objects that are
|
||||||
|
available.
|
||||||
|
A warning is produced for each missing object, unless the environment
|
||||||
|
variable
|
||||||
|
.Ev LD_SUPPRESS_WARNINGS
|
||||||
|
is set to a nonempty string.
|
||||||
|
.Pp
|
||||||
|
This is ignored for set-user-ID and set-group-ID programs.
|
||||||
|
.Pp
|
||||||
|
Missing shared objects can be ignored without errors if all the
|
||||||
|
following conditions hold:
|
||||||
|
.Bl -bullet
|
||||||
|
.It
|
||||||
|
They do not supply definitions for any required data symbols.
|
||||||
|
.It
|
||||||
|
No functions defined by them are called during program execution.
|
||||||
|
.It
|
||||||
|
The environment variable
|
||||||
|
.Ev LD_BIND_NOW
|
||||||
|
is unset or is set to the empty string.
|
||||||
|
.El
|
||||||
.It Ev LD_TRACE_LOADED_OBJECTS
|
.It Ev LD_TRACE_LOADED_OBJECTS
|
||||||
When set to a nonempty string, causes
|
When set to a nonempty string, causes
|
||||||
.Nm
|
.Nm
|
||||||
|
@ -106,7 +106,7 @@ library-name, major-version-number, minor-version-number
|
|||||||
recognises a number of environment variables that can be used to modify
|
recognises a number of environment variables that can be used to modify
|
||||||
its behaviour as follows:
|
its behaviour as follows:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width "LD_TRACE_LOADED_OBJECTS_PROGNAME"
|
.Bl -tag -width "LD_IGNORE_MISSING_OBJECTS"
|
||||||
.It Ev LD_LIBRARY_PATH
|
.It Ev LD_LIBRARY_PATH
|
||||||
A colon separated list of directories, overriding the default search path
|
A colon separated list of directories, overriding the default search path
|
||||||
for shared libraries.
|
for shared libraries.
|
||||||
@ -134,6 +134,30 @@ object. This is usually indicative of an incorrectly built library.
|
|||||||
When set to a nonempty string, no warning messages of any kind are
|
When set to a nonempty string, no warning messages of any kind are
|
||||||
issued. Normally, a warning is given if satisfactorily versioned
|
issued. Normally, a warning is given if satisfactorily versioned
|
||||||
library could not be found.
|
library could not be found.
|
||||||
|
.It Ev LD_IGNORE_MISSING_OBJECTS
|
||||||
|
When set to a nonempty string, makes it a nonfatal condition if
|
||||||
|
one or more required shared objects cannot be loaded.
|
||||||
|
Loading and execution proceeds using the objects that are
|
||||||
|
available.
|
||||||
|
A warning is produced for each missing object, unless the environment
|
||||||
|
variable
|
||||||
|
.Ev LD_SUPPRESS_WARNINGS
|
||||||
|
is set to a nonempty string.
|
||||||
|
.Pp
|
||||||
|
This is ignored for set-user-ID and set-group-ID programs.
|
||||||
|
.Pp
|
||||||
|
Missing shared objects can be ignored without errors if all the
|
||||||
|
following conditions hold:
|
||||||
|
.Bl -bullet
|
||||||
|
.It
|
||||||
|
They do not supply definitions for any required data symbols.
|
||||||
|
.It
|
||||||
|
No functions defined by them are called during program execution.
|
||||||
|
.It
|
||||||
|
The environment variable
|
||||||
|
.Ev LD_BIND_NOW
|
||||||
|
is unset or is set to the empty string.
|
||||||
|
.El
|
||||||
.It Ev LD_TRACE_LOADED_OBJECTS
|
.It Ev LD_TRACE_LOADED_OBJECTS
|
||||||
When set to a nonempty string, causes
|
When set to a nonempty string, causes
|
||||||
.Nm
|
.Nm
|
||||||
|
@ -188,6 +188,7 @@ static int careful;
|
|||||||
static int anon_fd = -1;
|
static int anon_fd = -1;
|
||||||
|
|
||||||
static char *ld_bind_now;
|
static char *ld_bind_now;
|
||||||
|
static char *ld_ignore_missing_objects;
|
||||||
static char *ld_library_path;
|
static char *ld_library_path;
|
||||||
static char *ld_preload;
|
static char *ld_preload;
|
||||||
static char *ld_tracing;
|
static char *ld_tracing;
|
||||||
@ -869,6 +870,15 @@ map_sods(parent)
|
|||||||
* "not found" message.
|
* "not found" message.
|
||||||
*/
|
*/
|
||||||
(void)alloc_link_map(NULL, sodp, parent, 0, 0);
|
(void)alloc_link_map(NULL, sodp, parent, 0, 0);
|
||||||
|
} else if (ld_ignore_missing_objects) {
|
||||||
|
char *msg;
|
||||||
|
/*
|
||||||
|
* Call __dlerror() even it we're not going to use
|
||||||
|
* the message, in order to clear the saved message.
|
||||||
|
*/
|
||||||
|
msg = __dlerror(); /* Should never be NULL */
|
||||||
|
if (!ld_suppress_warnings)
|
||||||
|
warnx("warning: %s", msg);
|
||||||
} else /* Give up */
|
} else /* Give up */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2022,6 +2032,7 @@ struct env_scan_tab {
|
|||||||
} scan_tab[] = {
|
} scan_tab[] = {
|
||||||
L("LD_LIBRARY_PATH=", 1, &ld_library_path)
|
L("LD_LIBRARY_PATH=", 1, &ld_library_path)
|
||||||
L("LD_PRELOAD=", 1, &ld_preload)
|
L("LD_PRELOAD=", 1, &ld_preload)
|
||||||
|
L("LD_IGNORE_MISSING_OBJECTS=", 1, &ld_ignore_missing_objects)
|
||||||
L("LD_TRACE_LOADED_OBJECTS=", 0, &ld_tracing)
|
L("LD_TRACE_LOADED_OBJECTS=", 0, &ld_tracing)
|
||||||
L("LD_BIND_NOW=", 0, &ld_bind_now)
|
L("LD_BIND_NOW=", 0, &ld_bind_now)
|
||||||
L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
|
L("LD_SUPPRESS_WARNINGS=", 0, &ld_suppress_warnings)
|
||||||
|
@ -106,7 +106,7 @@ library-name, major-version-number, minor-version-number
|
|||||||
recognises a number of environment variables that can be used to modify
|
recognises a number of environment variables that can be used to modify
|
||||||
its behaviour as follows:
|
its behaviour as follows:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -tag -width "LD_TRACE_LOADED_OBJECTS_PROGNAME"
|
.Bl -tag -width "LD_IGNORE_MISSING_OBJECTS"
|
||||||
.It Ev LD_LIBRARY_PATH
|
.It Ev LD_LIBRARY_PATH
|
||||||
A colon separated list of directories, overriding the default search path
|
A colon separated list of directories, overriding the default search path
|
||||||
for shared libraries.
|
for shared libraries.
|
||||||
@ -134,6 +134,30 @@ object. This is usually indicative of an incorrectly built library.
|
|||||||
When set to a nonempty string, no warning messages of any kind are
|
When set to a nonempty string, no warning messages of any kind are
|
||||||
issued. Normally, a warning is given if satisfactorily versioned
|
issued. Normally, a warning is given if satisfactorily versioned
|
||||||
library could not be found.
|
library could not be found.
|
||||||
|
.It Ev LD_IGNORE_MISSING_OBJECTS
|
||||||
|
When set to a nonempty string, makes it a nonfatal condition if
|
||||||
|
one or more required shared objects cannot be loaded.
|
||||||
|
Loading and execution proceeds using the objects that are
|
||||||
|
available.
|
||||||
|
A warning is produced for each missing object, unless the environment
|
||||||
|
variable
|
||||||
|
.Ev LD_SUPPRESS_WARNINGS
|
||||||
|
is set to a nonempty string.
|
||||||
|
.Pp
|
||||||
|
This is ignored for set-user-ID and set-group-ID programs.
|
||||||
|
.Pp
|
||||||
|
Missing shared objects can be ignored without errors if all the
|
||||||
|
following conditions hold:
|
||||||
|
.Bl -bullet
|
||||||
|
.It
|
||||||
|
They do not supply definitions for any required data symbols.
|
||||||
|
.It
|
||||||
|
No functions defined by them are called during program execution.
|
||||||
|
.It
|
||||||
|
The environment variable
|
||||||
|
.Ev LD_BIND_NOW
|
||||||
|
is unset or is set to the empty string.
|
||||||
|
.El
|
||||||
.It Ev LD_TRACE_LOADED_OBJECTS
|
.It Ev LD_TRACE_LOADED_OBJECTS
|
||||||
When set to a nonempty string, causes
|
When set to a nonempty string, causes
|
||||||
.Nm
|
.Nm
|
||||||
|
Loading…
Reference in New Issue
Block a user