From: Saleem Abdulrasool Date: Fri, 27 Aug 2021 15:51:47 +0000 (+0000) Subject: lib: avoid potential problems with `-fno-common` X-Git-Tag: elfutils-0.186~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d6dd0e5ad5c3366cbf701b4fb62b6d91be545f8;p=platform%2Fupstream%2Felfutils.git lib: avoid potential problems with `-fno-common` This properly homes the fallback function into a translation unit rather than trying to define an inline common definition for the fallback path. The intent of the original approach was to actually simply avoid adding a new source file that is used for the fallback path. However, that may cause trouble with multiple definitions if the symbol does not get vague linkage (which itself is not particularly great). This simplifies the behaviour at the cost of an extra inode. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index cf67674..60d3208 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2021-08-23 Saleem Abdulrasool + + * system.h: Remove inline definition for error and error_message_count + in the fallback path. + * Makefile.am (libeu_a_SOURCES): Add error.c. + * error.c: New file, moves the previous inline definitions to avoid + multiple definitions properly rather than relying on -fcommon and vague + linkage. + 2021-08-21 Saleem Abdulrasool * fixedsizehash.h: Remove unused STROF macro. diff --git a/lib/Makefile.am b/lib/Makefile.am index 97bf732..766fbcd 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -35,7 +35,7 @@ noinst_LIBRARIES = libeu.a libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \ crc32.c crc32_file.c \ - color.c printversion.c + color.c error.c printversion.c noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \ eu-config.h color.h printversion.h bpf.h \ diff --git a/lib/system.h b/lib/system.h index b963fd1..edbc848 100644 --- a/lib/system.h +++ b/lib/system.h @@ -45,21 +45,8 @@ #if defined(HAVE_ERROR_H) #include #elif defined(HAVE_ERR_H) -#include - -static int error_message_count = 0; - -static inline void error(int status, int errnum, const char *format, ...) { - va_list argp; - - va_start(argp, format); - verr(status, format, argp); - va_end(argp); - - if (status) - exit(status); - ++error_message_count; -} +extern int error_message_count; +void error(int status, int errnum, const char *format, ...); #else #error "err.h or error.h must be available" #endif