RFC PATCH: Enable dl_iterate_phdr inside libgcc_s.so.1 on *-*-freebsd*
Loren James Rittle
rittle@latour.labs.mot.com
Fri Sep 11 23:03:00 GMT 2009
This proposed mainline patch enables dl_iterate_phdr support inside
libgcc_s.so.1 (on FreeBSD 7 or later) on *-*-freebsd* to match the
configuration of the FreeBSD 7 system compiler. Yes, the system
compiler configuration actually defines __GLIBC__ (in a similar yet
more hard-coded fashion since they don't run configure) to enable the
code paths in crtstuff.c and unwind-dw2-fde-glibc.c ...
I have not committed this patch since the better alternative appears
to properly patch both crtstuff.c and unwind-dw2-fde-glibc.c, and
perhaps even rename unwind-dw2-fde-glibc.c to a more general name (now
that the same mechanism is properly supported outside of glibc hosts).
Comments?
Regards,
Loren
Index: config/t-freebsd
===================================================================
--- config/t-freebsd (revision 151644)
+++ config/t-freebsd (working copy)
@@ -1,3 +1,5 @@
+CRTSTUFF_T_CFLAGS = -D__GLIBC__="((__FreeBSD__>=7)*3)"
+
# Compile crtbeginS.o and crtendS.o with pic.
CRTSTUFF_T_CFLAGS_S = $(CRTSTUFF_T_CFLAGS) -fPIC
@@ -2,2 +4,7 @@
# Compile libgcc.a with pic.
-TARGET_LIBGCC2_CFLAGS += -fPIC
+TARGET_LIBGCC2_CFLAGS += -fPIC -D__GLIBC__="((__FreeBSD__>=7)*3)" -DElfW=__ElfN
+
+# Use unwind-dw2-fde-glibc
+LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \
+ $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c
+LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c
Index: config/freebsd-spec.h
===================================================================
--- config/freebsd-spec.h (revision 151644)
+++ config/freebsd-spec.h (working copy)
@@ -148,3 +148,12 @@
#else
#define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
#endif
+
+#if defined(HAVE_LD_EH_FRAME_HDR)
+#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+#endif
+
+/* Use --as-needed -lgcc_s for eh support. */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
More information about the Gcc-patches
mailing list