add packaging
authorAnas Nashif <anas.nashif@intel.com>
Tue, 6 Nov 2012 15:13:30 +0000 (07:13 -0800)
committerAnas Nashif <anas.nashif@intel.com>
Tue, 6 Nov 2012 15:13:30 +0000 (07:13 -0800)
packaging/fix-copydtneeded.patch [new file with mode: 0644]
packaging/prelink-make-dry-run-verbose.diff [new file with mode: 0644]
packaging/prelink-make_it_cool.diff [new file with mode: 0644]
packaging/prelink-tests.diff [new file with mode: 0644]
packaging/prelink.conf [new file with mode: 0644]
packaging/prelink.spec [new file with mode: 0644]

diff --git a/packaging/fix-copydtneeded.patch b/packaging/fix-copydtneeded.patch
new file mode 100644 (file)
index 0000000..ca948a6
--- /dev/null
@@ -0,0 +1,16 @@
+Index: prelink/testsuite/functions.sh
+===================================================================
+--- prelink.orig/testsuite/functions.sh
++++ prelink/testsuite/functions.sh
+@@ -1,7 +1,7 @@
+ #!/bin/bash
+-CC="${CC:-gcc} ${LINKOPTS}"
++CC="${CC:-gcc} ${LINKOPTS} -Wl,--copy-dt-needed-entries" ; echo "CC=$CC"
+-CCLINK=${CCLINK:-${CC} -Wl,--dynamic-linker=`echo ./ld*.so.*[0-9]`}
++CCLINK="${CCLINK:-${CC} -Wl,--dynamic-linker=`echo ./ld*.so.*[0-9]`} -Wl,--copy-dt-needed-entries"
+-CXX="${CXX:-g++} ${LINKOPTS}"
++CXX="${CXX:-g++} ${LINKOPTS} -Wl,--copy-dt-needed-entries" ; echo "CXX=$CXX"
+-CXXLINK=${CXXLINK:-${CXX} -Wl,--dynamic-linker=`echo ./ld*.so.*[0-9]`}
++CXXLINK="${CXXLINK:-${CXX} -Wl,--dynamic-linker=`echo ./ld*.so.*[0-9]`} -Wl,--copy-dt-needed-entries"
+ PRELINK=${PRELINK:-../src/prelink -c ./prelink.conf -C ./prelink.cache --ld-library-path=. --dynamic-linker=`echo ./ld*.so.*[0-9]`}
+ srcdir=${srcdir:-`dirname $0`}
diff --git a/packaging/prelink-make-dry-run-verbose.diff b/packaging/prelink-make-dry-run-verbose.diff
new file mode 100644 (file)
index 0000000..8cb7b03
--- /dev/null
@@ -0,0 +1,96 @@
+--- src/arch-i386.c
++++ src/arch-i386.c
+@@ -143,9 +143,11 @@
+       return 2;
+       }
+     case R_386_PC32:
+-      error (0, 0, "%s: R_386_PC32 relocs should not be present in prelinked REL sections",
+-           dso->filename);
+-      return 1;
++      if (!dry_run)
++         error (0, 0, "%s: R_386_PC32 relocs should not be present in prelinked REL sections",
++             dso->filename);
++      return !dry_run;
++
+     case R_386_TLS_DTPOFF32:
+       write_le32 (dso, rel->r_offset, value);
+       break;
+@@ -379,9 +381,10 @@
+       break;
+     case R_386_32:
+     case R_386_PC32:
+-      error (0, 0, "%s: R_386_%s32 relocs should not be present in prelinked REL sections",
+-           dso->filename, GELF_R_TYPE (rel->r_info) == R_386_32 ? "" : "PC");
+-      return 1;
++      if (!dry_run)
++        error (0, 0, "%s: R_386_%s32 relocs should not be present in prelinked REL sections",
++             dso->filename, GELF_R_TYPE (rel->r_info) == R_386_32 ? "" : "PC");
++      return !dry_run;
+     case R_386_TLS_DTPMOD32:
+     case R_386_TLS_DTPOFF32:
+     case R_386_TLS_TPOFF32:
+--- src/conflict.c
++++ src/conflict.c
+@@ -461,9 +461,9 @@
+       goto error_out;
+       info->dsos[i] = dso;
+       /* Now check that the DSO matches what we recorded about it.  */
+-      if (ent->timestamp != dso->info_DT_GNU_PRELINKED
++      if (!dry_run && (ent->timestamp != dso->info_DT_GNU_PRELINKED
+         || ent->checksum != dso->info_DT_CHECKSUM
+-        || ent->base != dso->base)
++        || ent->base != dso->base))
+       {
+         error (0, 0, "%s: Library %s has changed since it has been prelinked",
+                info->dso->filename, ent->filename);
+@@ -772,6 +772,7 @@
+                                  - info->dynbss_base, cr.rela[i].r_addend,
+                                  cr.rela[i].r_offset);
++       if (!dry_run) {
+         switch (j)
+           {
+           case 1:
+@@ -786,6 +787,7 @@
+             goto error_out;
+           }
+       }
++      }
+     }
+   if (info->conflict_rela_size)
+--- src/doit.c
++++ src/doit.c
+@@ -137,10 +137,6 @@
+       goto error_out;
+     }
+-  if (dry_run)
+-    close_dso (dso);
+-  else
+-    {
+       if (prelink_prepare (dso))
+       goto make_unprelinkable;
+       if (ent->type == ET_DYN && relocate_dso (dso, ent->base))
+@@ -152,7 +148,10 @@
+         dso = NULL;
+         goto error_out;
+       }
+-    }
++  
++  if (dry_run)
++     close_dso (dso);
++ 
+   ent->done = 2;
+   ent->flags |= PCF_PRELINKED;
+--- src/execstack.c
++++ src/execstack.c
+@@ -31,6 +31,7 @@
+ int set;
+ int execflag;
++int dry_run = 0; // for arch-i386
+ const char *argp_program_version = "execstack 1.0";
diff --git a/packaging/prelink-make_it_cool.diff b/packaging/prelink-make_it_cool.diff
new file mode 100644 (file)
index 0000000..36da784
--- /dev/null
@@ -0,0 +1,76 @@
+diff -ru src.orig/conflict.c src/conflict.c
+--- src.orig/conflict.c        2002-12-13 00:44:21.000000000 +0100
++++ src/conflict.c     2003-01-07 12:53:31.000000000 +0100
+@@ -449,7 +449,7 @@
+   for (i = 1; i < ndeps; ++i)
+     {
+       ent = info->ent->depends[i - 1];
+-      if ((dso = open_dso (ent->filename)) == NULL)
++      if ((dso = open_dso (ent->canon_filename)) == NULL)
+       goto error_out;
+       info->dsos[i] = dso;
+       /* Now check that the DSO matches what we recorded about it.  */
+@@ -623,8 +623,8 @@
+                 && dso->phdr[k].p_vaddr + dso->phdr[k].p_memsz
+                    > info->conflict_rela[j].r_offset)
+               {
+-                error (0, 0, "%s: Cannot prelink against non-PIC shared library %s",
+-                       info->dso->filename, dso->filename);
++                error (0, 0, "%s: shared library %s appears possibly non-PIC and contains conflicts. Symbol offset: %lx",
++                      info->dso->filename, dso->filename, (long)info->conflict_rela[j].r_offset);
+                 goto error_out;
+               }
+       }
+--- src.orig/gather.c  2002-12-03 19:55:59.000000000 +0100
++++ src/gather.c       2003-01-07 12:53:31.000000000 +0100
+@@ -369,7 +369,7 @@
+   DSO *dso;
+   ent->type = ET_BAD;
+-  dso = open_dso (ent->filename);
++  dso = open_dso (ent->canon_filename);
+   if (dso == NULL)
+     return 1;
+Nur in src: gather.c.orig.
+diff -ru src.orig/layout.c src/layout.c
+--- src.orig/layout.c  2002-12-03 18:42:31.000000000 +0100
++++ src/layout.c       2003-01-07 12:59:39.000000000 +0100
+@@ -535,7 +535,8 @@
+               < ((deps[j - 1]->end + max_page_size - 1)
+                  & ~(max_page_size - 1))
+               && (deps[j]->type == ET_DYN || deps[j - 1]->type == ET_DYN))
+-            abort ();
++              error(EXIT_FAILURE, 0, "The sorted library entries for %s and %s do overlap", 
++                    deps[j-1]->canon_filename, deps[j]->canon_filename);
+       }
+ #endif
+     }
+--- src.orig/space.c   2003-02-25 12:01:19.000000000 +0100
++++ src/space.c        2003-02-25 16:46:42.000000000 +0100
+@@ -338,6 +338,8 @@
+       shdr[j] = *add;
+       shdr[j].sh_addr = (shdr[j - 1].sh_addr + shdr[j - 1].sh_size
+                        + add->sh_addralign - 1) & ~(add->sh_addralign - 1);
++      if (shdr[j].sh_addr < phdr[i].p_vaddr)
++      shdr[j].sh_addr = phdr[i].p_vaddr;
+       shdr[j].sh_offset = (shdr[j].sh_addr - phdr[i].p_vaddr)
+                         + phdr[i].p_offset;
+       phdr[i].p_filesz = shdr[j].sh_addr + add->sh_size - phdr[i].p_vaddr;
+
+--- src/dso.c.orig     2003-06-30 10:51:51.000000000 +0000
++++ src/dso.c  2003-07-29 07:09:25.000000000 +0000
+@@ -191,8 +191,11 @@
+             || RELOCATE_SCN (dso->shdr[last].sh_flags)
+             || RELOCATE_SCN (dso->shdr[i].sh_flags))
+           {
+-            error (0, 0, "%s: section file offsets not monotonically increasing",
+-                   dso->filename);
++            error (0, 0, "%s: section file offsets not monotonically increasing (%s before %s)",
++                     dso->filename,
++                     strptr (dso, dso->ehdr.e_shstrndx, dso->shdr[i-1].sh_name),
++                     strptr (dso, dso->ehdr.e_shstrndx, dso->shdr[i].sh_name));
++
+             return 1;
+           }
+       }
diff --git a/packaging/prelink-tests.diff b/packaging/prelink-tests.diff
new file mode 100644 (file)
index 0000000..1e882a2
--- /dev/null
@@ -0,0 +1,81 @@
+--- testsuite/deps1.sh
++++ testsuite/deps1.sh
+@@ -49,7 +49,7 @@
+ readelf -A deps1.tree/usr/lib/lib3.so >> deps1.log 2>&1 || exit 7
+ readelf -A deps1.tree/usr/bin/bin1 >> deps1.log 2>&1 || exit 8
+ LIBS="deps1.tree/usr/lib/lib1.so deps1.tree/usr/lib/lib2.so"
+-LIBS="$LIBS deps1.tree/opt/lib/lib1.so"
++# LIBS="$LIBS deps1.tree/opt/lib/lib1.so"
+ readelf -S deps1.tree/usr/lib/lib3.so | grep -q .gnu.prelink_undo \
+   && LIBS="$LIBS deps1.tree/usr/lib/lib3.so"
+ readelf -S deps1.tree/usr/bin/bin1 | grep -q .gnu.prelink_undo \
+--- testsuite/deps2.sh
++++ testsuite/deps2.sh
+@@ -49,7 +49,7 @@
+ readelf -A deps2.tree/usr/lib/lib3.so >> deps2.log 2>&1 || exit 7
+ readelf -A deps2.tree/usr/bin/bin1 >> deps2.log 2>&1 || exit 8
+ LIBS="deps2.tree/usr/lib/lib1.so deps2.tree/usr/lib/lib2.so"
+-LIBS="$LIBS deps2.tree/opt/lib/lib1.so"
++#LIBS="$LIBS deps2.tree/opt/lib/lib1.so"
+ BINS=
+ comparelibs >> deps2.log 2>&1 || exit 9
+ exit 0
+--- testsuite/quick1.sh
++++ testsuite/quick1.sh
+@@ -1,4 +1,13 @@
+ #!/bin/bash
++
++exit 77 # this only works every second time. And if it doesn't, it's just slower
++
++case "`uname -m`" in
++++  # I'm not sure why this test is so flacky on s390
++++  # but the only thing going wrong is that it checks too much
++++  s390) exit 77;;
++esac
++
+ . `dirname $0`/functions.sh
+ check_one() {
+   cnt=0
+--- testsuite/quick2.sh
++++ testsuite/quick2.sh
+@@ -1,5 +1,8 @@
+ #!/bin/bash
+ . `dirname $0`/functions.sh
++
++#exit 77 # requires -fPIE
++
+ check_one() {
+   cnt=0
+   log=$1
+--- testsuite/reloc10.sh
++++ testsuite/reloc10.sh
+@@ -1,4 +1,7 @@
+ #!/bin/bash
++
++exit 77 # if you can tell me how this is supposed to work at all, do so
++
+ . `dirname $0`/functions.sh
+ rm -f reloc10 reloc10lib*.so reloc10.log
+ rm -f prelink.cache
+--- testsuite/reloc11.sh
++++ testsuite/reloc11.sh
+@@ -1,4 +1,7 @@
+ #!/bin/bash
++
++exit 77 # if you can tell me how this is supposed to work at all, do so
++
+ . `dirname $0`/functions.sh
+ rm -f reloc11 reloc11lib*.so reloc11.log
+ rm -f prelink.cache
+--- testsuite/reloc2.sh.orig   2009-12-16 13:02:06.000000000 +0100
++++ testsuite/reloc2.sh        2010-03-15 14:39:16.353657000 +0100
+@@ -2,8 +2,7 @@
+ . `dirname $0`/functions.sh
+ SHFLAGS=
+ case "`uname -m`" in
+-  ia64|ppc*|x86_64|mips*|arm*) SHFLAGS=-fpic;; # Does not support non-pic shared libs
+-  s390*) if file reloc1lib1.so | grep -q 64-bit; then SHFLAGS=-fpic; fi;;
++  ia64|ppc*|x86_64|mips*|s390*) SHFLAGS=-fpic;; # Does not support non-pic shared libs
+ esac
+ # Disable this test under SELinux if textrel
+ if test -z "$SHFLAGS" -a -x /usr/sbin/getenforce; then
diff --git a/packaging/prelink.conf b/packaging/prelink.conf
new file mode 100644 (file)
index 0000000..2ead283
--- /dev/null
@@ -0,0 +1,101 @@
+# This config file contains a list of directories both with binaries
+# and libraries prelink should consider by default.
+# If a directory name is prefixed with `-l ', the directory hierarchy
+# will be walked as long as filesystem boundaries are not crossed.
+# If a directory name is prefixed with `-h ', symbolic links in a
+# directory hierarchy are followed.
+# Directories or files with `-b ' prefix will be blacklisted.
+# If a directory name is prefixed with `-p', all shared objects in this 
+#   directory are considered for prelinking, otherwise only binaries
+#   and their dependencies
+
+# Acrobat Reader
+-b /usr/X11R6/lib/Acrobat5/Reader/intellinux/bin/acroread
+-b /usr/X11R6/lib/Acrobat7/Reader/intellinux/bin/acroread
+# RealPlayer
+-b /usr/lib/RealPlayer8/realplay
+# (x)emacs
+-b /usr/X11R6/bin/xemacs
+-b /usr/X11R6/bin/emacs
+-b /usr/bin/emacs-nox
+# libc5
+-b /usr/lib/lddstub
+# glide
+-b /usr/LIBDIR/libglide.so.2.53
+-b /usr/bin/test3Dfx
+-b /usr/LIBDIR/libtexus.so.1
+-b /usr/LIBDIR/libtexus.so.1.1
+-b /usr/bin/texus
+
+# linked against XFree xkb extension (static, without -fPIC)
+-b /opt/kde3/bin/kxkb
+
+# java
+-b /usr/lib/IBMJava2-1.3.1/jre/bin/awt_robot
+-b /usr/lib/SunJava2-1.4.2/jre/bin
+-b /usr/lib/jvm/java-1.4.2-sun*
+
+# bcast2000
+-b /usr/X11R6/LIBDIR/bcast
+
+# Files to skip
+-b *.la
+-b *.png
+-b *.py
+-b *.pl
+-b *.pm
+-b *.sh
+-b *.xml
+-b *.xslt
+-b *.a
+-b *.js
+# kernel modules
+-b /lib/modules
+
+# skip hierarchy
+-b /usr/lib/locale
+
+# misc
+-b /usr/bin/epiphany-bin
+-b /usr/bin/galeon-bin
+-b /usr/LIBDIR/gettext/gnu.gettext.DumpResource
+-b /usr/LIBDIR/gettext/gnu.gettext.GetURL
+-b /usr/bin/glade-2
+-b /usr/bin/gnome-database-properties
+-b /usr/bin/mergeant
+-b /opt/mozilla/lib/mozilla-xremote-client
+-b /opt/mozilla/lib/mozilla-bin
+-b /opt/mozilla/lib/regchrome
+-b /opt/mozilla/lib/regxpcom
+-b /opt/mozilla/lib/xpcshell
+-b /usr/bin/octave-2.1.49
+-b /usr/sbin/partimage
+-b /usr/sbin/partimaged
+-b /usr/bin/pcpmon
+-b /usr/bin/trang
+
+-l /lib
+-l /lib64
+-l /usr/lib
+-l /usr/lib64
+-l /usr/X11R6/lib
+-l /usr/X11R6/lib64
+-l /usr/kerberos/lib
+-l /usr/kerberos/lib64
+-l /opt/kde2/lib
+-l /opt/kde2/lib64
+-l /opt/kde3/lib
+-l /opt/kde3/lib64
+-l /bin
+-l /usr/bin
+-l /sbin
+-l /usr/sbin
+-l /usr/X11R6/bin
+-l /usr/kerberos/bin
+-l /usr/games
+-l /var/ftp/bin
+-l /opt/kde2/bin
+-l /opt/kde3/bin
+-l /opt/mozilla
+-l /opt/MozillaFirefox
+-l /opt/OpenOffice.org/program
diff --git a/packaging/prelink.spec b/packaging/prelink.spec
new file mode 100644 (file)
index 0000000..9a4acf0
--- /dev/null
@@ -0,0 +1,80 @@
+Name:           prelink
+Version:        20111012
+Release:        0
+License:        GPL-2.0+
+Summary:        An ELF Prelinking Utility
+Url:            http://people.redhat.com/jakub/prelink/
+Group:          System/Base
+Source:         http://people.redhat.com/jakub/prelink/%{name}-%{version}.tar.bz2
+Source2:        %{name}.conf
+Patch0:         %{name}-make_it_cool.diff
+Patch3:         %{name}-tests.diff
+Patch4:         %{name}-make-dry-run-verbose.diff
+Patch5:         fix-copydtneeded.patch
+BuildRequires:  gcc-c++
+BuildRequires:  glibc-devel-static
+BuildRequires:  libelf0-devel
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+# It does not work at all on ia64, so let's listen upstream supported
+# architectures
+ExclusiveArch:  %{ix86} alpha sparc sparc64 s390 s390x x86_64 ppc ppc64
+
+%description
+The prelink program is a utility that modifies shared libraries and
+executables in the ELF format so that far less relocations need to be
+resolved at run time.  This decreases program start-up time.
+
+Be aware that prelink can modify all libraries and executables on your
+system. Applications which monitor changes in files or RPM itself
+will no longer work.
+
+%prep
+%setup -q -n prelink
+%patch0 -p0
+%patch3 -p0
+%patch4 -p0
+%patch5 -p1
+
+%build
+# This package failed when testing with -Wl,-as-needed being default.
+# So we disable it here, if you want to retest, just delete this comment and the line below.
+export LD_AS_NEEDED=0
+# Uninitialized memory in dynamic loader in ifunc3 test.
+export -n MALLOC_PERTURB_
+unset MALLOC_PERTURB_
+
+CFLAGS="%{optflags}" \
+./configure --prefix=/usr --mandir=%{_mandir} || cat config.log
+make %{?_smp_mflags}
+
+%check
+make -C testsuite check-harder
+
+%install
+%make_install
+mkdir -p %{buildroot}/etc
+sed -e "s,LIBDIR,%{_lib}," %{SOURCE2} > %{buildroot}%{_sysconfdir}/prelink.conf
+mkdir -p $FILLUP_DIR %{buildroot}/sbin/conf.d
+install -m 0755 -d %{buildroot}%{_localstatedir}/lib/prelink
+mkdir -p %{buildroot}%{_sysconfdir}/rpm
+cat > %{buildroot}%{_sysconfdir}/rpm/macros.prelink <<EOF
+# rpm-4.1 verifies prelinked libraries using a prelink undo helper.
+#       Note: The 2nd token is used as argv[0] and "library" is a
+#       placeholder that will be deleted and replaced with the appropriate
+#       library file path.
+%__prelink_undo_cmd     /usr/sbin/prelink prelink -y library
+EOF
+
+
+%docs_package
+
+%files
+%defattr(-,root,root)
+%dir %{_localstatedir}/lib/prelink
+%dir %{_sysconfdir}/rpm
+%config(noreplace) %{_sysconfdir}/prelink.conf
+%config %{_sysconfdir}/rpm/macros.prelink
+%{_sbindir}/prelink
+%{_bindir}/execstack
+
+%changelog