Hi,

This has been in my tree for a while, since fixing a bunch of TEXTREL in
OpenSSL some time ago.

Text relocations are cases where the linker has to modify the executable
code of a library to fixup jump addresses to adjust for the library's
load address. They waste memory because each program that uses the
library triggers copy-on-write for the .text pages that need fixups
rather than allowing them to be shared though the buffer cache.

This diff adds a warning to bsd.lib.mk when it finds a TEXTREL in a
library. At the moment it finds one in /usr/X11R6/lib/libGL.so.10.0, but
its main value is in trying to prevent new ones from arising.

Index: bsd.lib.mk
===================================================================
RCS file: /cvs/src/share/mk/bsd.lib.mk,v
retrieving revision 1.60
diff -u -p -r1.60 bsd.lib.mk
--- bsd.lib.mk  30 Jul 2010 19:23:38 -0000      1.60
+++ bsd.lib.mk  15 Oct 2010 10:45:18 -0000
@@ -209,6 +209,11 @@ lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINO
        ${CC} -shared ${PICFLAG} \
            -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
            `${LORDER} ${SOBJS}|tsort -q` ${LDADD}
+       @if ${OBJDUMP} -p lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} | \
+           grep -q TEXTREL ; then \
+               echo "Warning: lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}" \
+                    "has TEXTREL, which is highly inefficient" ; \
+       fi
 
 LOBJS+=        ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
 LLIBS?=        -lc
Index: sys.mk
===================================================================
RCS file: /cvs/src/share/mk/sys.mk,v
retrieving revision 1.59
diff -u -p -r1.59 sys.mk
--- sys.mk      24 Jul 2010 15:31:19 -0000      1.59
+++ sys.mk      15 Oct 2010 10:45:18 -0000
@@ -22,6 +22,7 @@ AR?=          ar
 ARFLAGS?=      rl
 RANLIB?=       ranlib
 LORDER?=       lorder
+OBJDUMP?=      objdump
 
 AS?=           as
 AFLAGS?=       ${DEBUG}

Reply via email to