This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Allow to build for non-ELF target


Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
---
 backends/Makefile.am |  5 ++++-
 configure.ac         | 13 ++++++++++++-
 lib/eu-config.h      |  4 ++++
 libdw/Makefile.am    |  5 ++++-
 libelf/Makefile.am   |  5 ++++-
 5 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/backends/Makefile.am b/backends/Makefile.am
index b553ec3..eed46d7 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -31,6 +31,9 @@ include $(top_srcdir)/config/eu.am
 AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
 	   -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw
 
+if ELF
+AM_LDFLAGS = -Wl,-z,defs
+endif
 
 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
 	  tilegx m68k bpf
@@ -136,7 +139,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
 	$(AM_V_CCLD)$(LINK) -shared -o $(@:.map=.so) \
 		-Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
 		-Wl,--version-script,$(@:.so=.map) \
-		-Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw)
+		-Wl,--as-needed $(libelf) $(libdw)
 	@$(textrel_check)
 
 libebl_i386.so: $(cpu_i386)
diff --git a/configure.ac b/configure.ac
index e5503f1..fa731c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,13 +121,24 @@ CFLAGS="$old_CFLAGS"])
 AS_IF([test "x$ac_cv_c99" != xyes],
       AC_MSG_ERROR([gcc with GNU99 support required]))
 
+AC_CACHE_CHECK([the output format of the linker is ELF], ac_cv_elf,[dnl
+case `$CC -Wl,-print-output-format -nodefaultlibs -nostartfiles` in
+ elf*) ac_cv_elf=yes ;;
+ *)   ac_cv_elf=no ;;
+esac])
+AM_CONDITIONAL(ELF, test "$ac_cv_elf" = yes)
+AS_IF(test "$ac_cv_elf" = yes, elf_val=0, elf_val=1)
+AC_SUBST(ELF, $elf_val)
+AH_TEMPLATE([ELF], [whether the output format of the linker is ELF])
+
 AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
 # Use the same flags that we use for our DSOs, so the test is representative.
 # Some old compiler/linker/libc combinations fail some ways and not others.
 save_CFLAGS="$CFLAGS"
 save_LDFLAGS="$LDFLAGS"
 CFLAGS="-fPIC $CFLAGS"
-LDFLAGS="-shared -Wl,-z,defs,-z,relro $LDFLAGS"
+LDFLAGS="-shared $LDFLAGS"
+AS_IF([test "$ac_cv_elf" = yes], [LDFLAGS="-Wl,-z,defs,-z,relro $LDFLAGS"])
 AC_LINK_IFELSE([dnl
 AC_LANG_PROGRAM([[#include <stdlib.h>
 #undef __thread
diff --git a/lib/eu-config.h b/lib/eu-config.h
index 400cdc6..5f1dda3 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -68,8 +68,12 @@
 #define internal_strong_alias(name, aliasname) \
   extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function;
 
+#ifdef ELF
 #define attribute_hidden \
   __attribute__ ((visibility ("hidden")))
+#else
+#define attribute_hidden
+#endif
 
 /* Define ALLOW_UNALIGNED if the architecture allows operations on
    unaligned memory locations.  */
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 082d96c..a637e18 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -102,13 +102,16 @@ endif
 libdw_pic_a_SOURCES =
 am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
 
+if ELF
+libdw_so_LDFLAGS = -Wl,-z,defs
+endif
 libdw_so_SOURCES =
 libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
 	  ../libdwfl/libdwfl_pic.a ../libebl/libebl.a \
 	  ../libelf/libelf.so
 # The rpath is necessary for libebl because its $ORIGIN use will
 # not fly in a setuid executable that links in libdw.
-	$(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--soname,$@.$(VERSION),-z,defs \
+	$(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--soname,$@.$(VERSION) \
 		-Wl,--enable-new-dtags,-rpath,$(pkglibdir) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 167a832..41302c3 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -100,11 +100,14 @@ if USE_LOCKS
 libelf_so_LDLIBS += -lpthread
 endif
 
+if ELF
+libelf_so_LDFLAGS = -Wl,-z,defs,-z,relro
+endif
 libelf_so_SOURCES =
 libelf.so$(EXEEXT): libelf_pic.a libelf.map
 	$(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 		-Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
-		-Wl,--soname,$@.$(VERSION),-z,defs,-z,relro $(libelf_so_LDLIBS)
+		-Wl,--soname,$@.$(VERSION) $(libelf_so_LDLIBS)
 	@$(textrel_check)
 	$(AM_V_at)ln -fs $@ $@.$(VERSION)
 
-- 
2.10.0

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]