public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: Versioned symbols in elfutils and uClibc
Date: Thu, 23 Apr 2015 00:18:10 +0300	[thread overview]
Message-ID: <1429737490-10478-1-git-send-email-jcmvbkbc@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5288 bytes --]

Hello,

I've got a segfault in ltrace on uClibc-based system, caused by infinite
recursion in the dwfl_report_elf function [1]. This happens because there
is no symbol versioning support in uClibc and there are two versions of
that function, one of them calling the other. Does the below patch look
like a good solution to this?

[1] http://permalink.gmane.org/gmane.comp.lib.uclibc.buildroot/113856

---8<---
From: Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH] Allow disabling symbol versioning at configure time

Due to missing symbol versioning support in uClibc calls to versioned
functions that internally call different version of themselves results
in infinite recursion.

Introduce macro SYMBOL_VERSIONING and use it instead of plain SHARED to
decide whether symbol versioning is needed. Control this macro
definition with new configure option --disable-symbol-versioning.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 config/eu.am                   | 10 ++++++++--
 configure.ac                   |  5 +++++
 lib/eu-config.h                |  6 +++---
 libdwfl/core-file.c            |  2 +-
 libdwfl/dwfl_module_build_id.c |  2 +-
 libdwfl/dwfl_report_elf.c      |  2 +-
 6 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/config/eu.am b/config/eu.am
index faf8add..6103a3e 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -38,16 +38,22 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
 
 COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
 
+DEFS.os = -DPIC -DSHARED
+if SYMBOL_VERSIONING
+DEFS.os += -DSYMBOL_VERSIONING
+else
+endif
+
 %.os: %.c %.o
 if AMDEP
-	if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+	if $(COMPILE.os) -c -o $@ -fpic $(DEFS.os) -MT $@ -MD -MP \
 	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
 	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
 	     rm -f "$(DEPDIR)/$*.Tpo"; \
 	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
 	fi
 else
-	$(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
+	$(COMPILE.os) -c -o $@ -fpic $(DEFS.os) $<
 endif
 
 CLEANFILES = *.gcno *.gcda
diff --git a/configure.ac b/configure.ac
index ed2c964..e3226f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,11 @@ AS_HELP_STRING([--disable-textrelcheck],
                [Disable textrelcheck being a fatal error]))
 AM_CONDITIONAL(FATAL_TEXTREL, [test "x$enable_textrelcheck" != "xno"])
 
+AC_ARG_ENABLE([symbol-versioning],
+AS_HELP_STRING([--disable-symbol-versioning],
+               [Disable symbol versioning in shared objects]))
+AM_CONDITIONAL(SYMBOL_VERSIONING, [test "x$enable_symbol_versioning" != "xno"])
+
 dnl The directories with content.
 
 dnl Documentation.
diff --git a/lib/eu-config.h b/lib/eu-config.h
index 3afff26..5bb21c1 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -163,7 +163,7 @@ asm (".section predict_data, \"aw\"; .previous\n"
 #define ELFUTILS_HEADER(name) <lib##name.h>
 
 
-#ifdef SHARED
+#ifdef SYMBOL_VERSIONING
 # define OLD_VERSION(name, version) \
   asm (".globl _compat." #version "." #name "\n" \
        "_compat." #version "." #name " = " #name "\n" \
@@ -181,8 +181,8 @@ asm (".section predict_data, \"aw\"; .previous\n"
 # define OLD_VERSION(name, version) /* Nothing for static linking.  */
 # define NEW_VERSION(name, version) /* Nothing for static linking.  */
 # define COMPAT_VERSION_NEWPROTO(name, version, prefix) \
-  error "should use #ifdef SHARED"
-# define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SHARED"
+  error "should use #ifdef SYMBOL_VERSIONING"
+# define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SYMBOL_VERSIONING"
 #endif
 
 
diff --git a/libdwfl/core-file.c b/libdwfl/core-file.c
index 324e9d2..bbe0899 100644
--- a/libdwfl/core-file.c
+++ b/libdwfl/core-file.c
@@ -588,7 +588,7 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf, const char *executable)
 INTDEF (dwfl_core_file_report)
 NEW_VERSION (dwfl_core_file_report, ELFUTILS_0.158)
 
-#ifdef SHARED
+#ifdef SYMBOL_VERSIONING
 int _compat_without_executable_dwfl_core_file_report (Dwfl *dwfl, Elf *elf);
 COMPAT_VERSION_NEWPROTO (dwfl_core_file_report, ELFUTILS_0.146,
 			 without_executable)
diff --git a/libdwfl/dwfl_module_build_id.c b/libdwfl/dwfl_module_build_id.c
index 350bbf8..c9a42ca 100644
--- a/libdwfl/dwfl_module_build_id.c
+++ b/libdwfl/dwfl_module_build_id.c
@@ -101,7 +101,7 @@ dwfl_module_build_id (Dwfl_Module *mod,
 INTDEF (dwfl_module_build_id)
 NEW_VERSION (dwfl_module_build_id, ELFUTILS_0.138)
 
-#ifdef SHARED
+#ifdef SYMBOL_VERSIONING
 COMPAT_VERSION (dwfl_module_build_id, ELFUTILS_0.130, vaddr_at_end)
 
 int
diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c
index 3a4ae2e..624284c 100644
--- a/libdwfl/dwfl_report_elf.c
+++ b/libdwfl/dwfl_report_elf.c
@@ -321,7 +321,7 @@ dwfl_report_elf (Dwfl *dwfl, const char *name, const char *file_name, int fd,
 INTDEF (dwfl_report_elf)
 NEW_VERSION (dwfl_report_elf, ELFUTILS_0.156)
 
-#ifdef SHARED
+#ifdef SYMBOL_VERSIONING
 Dwfl_Module *
   _compat_without_add_p_vaddr_dwfl_report_elf (Dwfl *dwfl, const char *name,
 					       const char *file_name, int fd,
-- 
1.8.1.4


             reply	other threads:[~2015-04-22 21:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 21:18 Max Filippov [this message]
2015-04-23 19:39 Mark Wielaard
2015-04-23 20:20 Max Filippov
2015-04-23 20:56 Mark Wielaard
2015-04-23 22:24 Max Filippov
2015-04-24 11:49 Anthony G. Basile
2015-04-24 13:36 Mark Wielaard
2015-04-24 16:13 Max Filippov
2015-04-25  9:41 Mark Wielaard
2015-04-25 13:14 Anthony G. Basile
2015-04-25 13:29 Anthony G. Basile
2015-04-27  2:12 Max Filippov
2015-04-28 10:01 Max Filippov
2015-04-28 17:04 Mark Wielaard
2015-04-28 17:10 Mark Wielaard
2015-04-28 17:34 Mark Wielaard
2015-04-28 17:35 Anthony G. Basile
2015-04-28 17:35 Mark Wielaard
2015-04-29  0:29 Max Filippov
2015-04-29  0:35 Max Filippov
2015-05-01  8:52 Mark Wielaard
2015-05-03 18:18 Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429737490-10478-1-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=elfutils-devel@lists.fedorahosted.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).