summaryrefslogtreecommitdiffstats
path: root/patches/prelink-0.0.20071009
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2008-10-16 16:06:09 +0000
committerMarc Kleine-Budde <mkl@pengutronix.de>2008-10-16 16:06:09 +0000
commit74455bff4f71f05f9e1f821054c00e72e78d4301 (patch)
tree2c18f9fa0a994916b38fe939e1f1e2da9bccd6e0 /patches/prelink-0.0.20071009
parent8240aec151c8dcce20b62668ebaa3bdfa60d1ac4 (diff)
downloadptxdist-74455bff4f71f05f9e1f821054c00e72e78d4301.tar.gz
ptxdist-74455bff4f71f05f9e1f821054c00e72e78d4301.tar.xz
* prelink-0.0.20071009:
new git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-trunk@8930 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'patches/prelink-0.0.20071009')
-rw-r--r--patches/prelink-0.0.20071009/generic/Makefile.in.dpatch34
-rw-r--r--patches/prelink-0.0.20071009/generic/arm_eabi.patch302
-rw-r--r--patches/prelink-0.0.20071009/generic/dso.c.dpatch39
-rw-r--r--patches/prelink-0.0.20071009/generic/fsync.dpatch46
-rw-r--r--patches/prelink-0.0.20071009/generic/init.dpatch86
-rw-r--r--patches/prelink-0.0.20071009/generic/layout.c.dpatch49
-rw-r--r--patches/prelink-0.0.20071009/generic/md5sha.dpatch44
-rw-r--r--patches/prelink-0.0.20071009/generic/prelink.h.dpatch71
-rw-r--r--patches/prelink-0.0.20071009/generic/series7
9 files changed, 678 insertions, 0 deletions
diff --git a/patches/prelink-0.0.20071009/generic/Makefile.in.dpatch b/patches/prelink-0.0.20071009/generic/Makefile.in.dpatch
new file mode 100644
index 000000000..db646824e
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/Makefile.in.dpatch
@@ -0,0 +1,34 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Changed optimization level.
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+--- prelink-0.0.20030902.orig/src/Makefile.in 2003-07-01 14:38:41.000000000 +0000
++++ prelink-0.0.20030902/src/Makefile.in 2003-09-16 23:26:16.000000000 +0000
+@@ -108,7 +108,7 @@
+ $(prelink_SYSDEPS)
+
+ prelink_LDADD = @LIBGELF@
+-prelink_LDFLAGS = -all-static
++#prelink_LDFLAGS = -all-static
+
+ extra_DIST = makecrc.c
+ subdir = src
diff --git a/patches/prelink-0.0.20071009/generic/arm_eabi.patch b/patches/prelink-0.0.20071009/generic/arm_eabi.patch
new file mode 100644
index 000000000..010599b99
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/arm_eabi.patch
@@ -0,0 +1,302 @@
+From 459338856d2a426602e58158f60c678785a9ae28 Mon Sep 17 00:00:00 2001
+From: <rpurdie@openembedded.org>
+Date: Tue, 22 Jan 2008 09:16:45 +0000
+Subject: [PATCH] prelink: Update to the last release (20071027) and pull eabi fixes from poky
+
+---
+ src/arch-arm.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 172 insertions(+), 5 deletions(-)
+
+Index: prelink-0.0.20061027/src/arch-arm.c
+===================================================================
+--- prelink-0.0.20061027.orig/src/arch-arm.c 2006-08-13 16:18:17.000000000 +0100
++++ prelink-0.0.20061027/src/arch-arm.c 2007-09-04 12:29:06.000000000 +0100
+@@ -145,6 +145,26 @@ arm_prelink_rel (struct prelink_info *in
+ error (0, 0, "%s: R_ARM_PC24 relocs with non-zero addend should not be present in prelinked REL sections",
+ dso->filename);
+ return 1;
++ /* DTPOFF32, DTPMOD32 and TPOFF32 is impossible to predict unless prelink
++ sets the rules. Also for DTPOFF32/TPOFF32 there is REL->RELA problem. */
++ case R_ARM_TLS_DTPOFF32:
++ if (dso->ehdr.e_type == ET_EXEC)
++ error (0, 0, "%s: R_ARM_TLS_DTPOFF32 relocs should not be present in prelinked ET_EXEC REL sections",
++ dso->filename);
++ break;
++ case R_ARM_TLS_DTPMOD32:
++ if (dso->ehdr.e_type == ET_EXEC)
++ {
++ error (0, 0, "%s: R_ARM_TLS_DTPMOD32 reloc in executable?",
++ dso->filename);
++ return 1;
++ }
++ break;
++ case R_ARM_TLS_TPOFF32:
++ if (dso->ehdr.e_type == ET_EXEC)
++ error (0, 0, "%s: R_ARM_TLS_TPOFF32 relocs should not be present in prelinked ET_EXEC REL sections",
++ dso->filename);
++ break;
+ case R_ARM_COPY:
+ if (dso->ehdr.e_type == ET_EXEC)
+ /* COPY relocs are handled specially in generic code. */
+@@ -195,6 +215,25 @@ arm_prelink_rela (struct prelink_info *i
+ write_le32 (dso, rela->r_offset,
+ (read_ule32 (dso, rela->r_offset) & 0xff000000) | val);
+ break;
++ case R_ARM_TLS_DTPOFF32:
++ if (dso->ehdr.e_type == ET_EXEC)
++ write_le32 (dso, rela->r_offset, value + rela->r_addend);
++ break;
++ /* DTPMOD32 and TPOFF32 are impossible to predict unless prelink
++ sets the rules. */
++ case R_ARM_TLS_DTPMOD32:
++ if (dso->ehdr.e_type == ET_EXEC)
++ {
++ error (0, 0, "%s: R_ARM_TLS_DTPMOD32 reloc in executable?",
++ dso->filename);
++ return 1;
++ }
++ break;
++ case R_ARM_TLS_TPOFF32:
++ if (dso->ehdr.e_type == ET_EXEC && info->resolvetls)
++ write_le32 (dso, rela->r_offset,
++ value + rela->r_addend + info->resolvetls->offset);
++ break;
+ case R_ARM_COPY:
+ if (dso->ehdr.e_type == ET_EXEC)
+ /* COPY relocs are handled specially in generic code. */
+@@ -315,6 +354,7 @@ arm_prelink_conflict_rel (DSO *dso, stru
+ {
+ GElf_Addr value;
+ struct prelink_conflict *conflict;
++ struct prelink_tls *tls;
+ GElf_Rela *ret;
+
+ if (GELF_R_TYPE (rel->r_info) == R_ARM_RELATIVE
+@@ -324,8 +364,32 @@ arm_prelink_conflict_rel (DSO *dso, stru
+ conflict = prelink_conflict (info, GELF_R_SYM (rel->r_info),
+ GELF_R_TYPE (rel->r_info));
+ if (conflict == NULL)
+- return 0;
+- value = conflict_lookup_value (conflict);
++ {
++ if (info->curtls == NULL)
++ return 0;
++ switch (GELF_R_TYPE (rel->r_info))
++ {
++ /* Even local DTPMOD and {D,}TPOFF relocs need conflicts. */
++ case R_ARM_TLS_DTPMOD32:
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ break;
++ default:
++ return 0;
++ }
++ value = 0;
++ }
++ else
++ {
++ /* DTPOFF32 wants to see only real conflicts, not lookups
++ with reloc_class RTYPE_CLASS_TLS. */
++ if (GELF_R_TYPE (rel->r_info) == R_ARM_TLS_DTPOFF32
++ && conflict->lookup.tls == conflict->conflict.tls
++ && conflict->lookupval == conflict->conflictval)
++ return 0;
++
++ value = conflict_lookup_value (conflict);
++ }
+ ret = prelink_conflict_add_rela (info);
+ if (ret == NULL)
+ return 1;
+@@ -342,6 +406,33 @@ arm_prelink_conflict_rel (DSO *dso, stru
+ error (0, 0, "%s: R_ARM_%s relocs should not be present in prelinked REL sections",
+ dso->filename, GELF_R_TYPE (rel->r_info) == R_ARM_ABS32 ? "ABS32" : "PC24");
+ return 1;
++ case R_ARM_TLS_DTPMOD32:
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ if (conflict != NULL
++ && (conflict->reloc_class != RTYPE_CLASS_TLS
++ || conflict->lookup.tls == NULL))
++ {
++ error (0, 0, "%s: R_ARM_TLS not resolving to STT_TLS symbol",
++ dso->filename);
++ return 1;
++ }
++ tls = conflict ? conflict->lookup.tls : info->curtls;
++ ret->r_info = GELF_R_INFO (0, R_ARM_ABS32);
++ switch (GELF_R_TYPE (rel->r_info))
++ {
++ case R_ARM_TLS_DTPMOD32:
++ ret->r_addend = tls->modid;
++ break;
++ case R_ARM_TLS_DTPOFF32:
++ ret->r_addend = value + read_ule32 (dso, rel->r_offset);
++ break;
++ case R_ARM_TLS_TPOFF32:
++ ret->r_addend = value + read_ule32 (dso, rel->r_offset)
++ + tls->offset;
++ break;
++ }
++ break;
+ case R_ARM_COPY:
+ error (0, 0, "R_ARM_COPY should not be present in shared libraries");
+ return 1;
+@@ -359,6 +450,7 @@ arm_prelink_conflict_rela (DSO *dso, str
+ {
+ GElf_Addr value;
+ struct prelink_conflict *conflict;
++ struct prelink_tls *tls;
+ GElf_Rela *ret;
+ Elf32_Sword val;
+
+@@ -369,8 +461,32 @@ arm_prelink_conflict_rela (DSO *dso, str
+ conflict = prelink_conflict (info, GELF_R_SYM (rela->r_info),
+ GELF_R_TYPE (rela->r_info));
+ if (conflict == NULL)
+- return 0;
+- value = conflict_lookup_value (conflict);
++ {
++ if (info->curtls == NULL)
++ return 0;
++ switch (GELF_R_TYPE (rela->r_info))
++ {
++ /* Even local DTPMOD and {D,}TPOFF relocs need conflicts. */
++ case R_ARM_TLS_DTPMOD32:
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ break;
++ default:
++ return 0;
++ }
++ value = 0;
++ }
++ else
++ {
++ /* DTPOFF32 wants to see only real conflicts, not lookups
++ with reloc_class RTYPE_CLASS_TLS. */
++ if (GELF_R_TYPE (rela->r_info) == R_ARM_TLS_DTPOFF32
++ && conflict->lookup.tls == conflict->conflict.tls
++ && conflict->lookupval == conflict->conflictval)
++ return 0;
++
++ value = conflict_lookup_value (conflict);
++ }
+ ret = prelink_conflict_add_rela (info);
+ if (ret == NULL)
+ return 1;
+@@ -398,6 +514,32 @@ arm_prelink_conflict_rela (DSO *dso, str
+ case R_ARM_COPY:
+ error (0, 0, "R_ARM_COPY should not be present in shared libraries");
+ return 1;
++ case R_ARM_TLS_DTPMOD32:
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ if (conflict != NULL
++ && (conflict->reloc_class != RTYPE_CLASS_TLS
++ || conflict->lookup.tls == NULL))
++ {
++ error (0, 0, "%s: R_386_TLS not resolving to STT_TLS symbol",
++ dso->filename);
++ return 1;
++ }
++ tls = conflict ? conflict->lookup.tls : info->curtls;
++ ret->r_info = GELF_R_INFO (0, R_ARM_ABS32);
++ switch (GELF_R_TYPE (rela->r_info))
++ {
++ case R_ARM_TLS_DTPMOD32:
++ ret->r_addend = tls->modid;
++ break;
++ case R_ARM_TLS_DTPOFF32:
++ ret->r_addend = value + rela->r_addend;
++ break;
++ case R_ARM_TLS_TPOFF32:
++ ret->r_addend = value + rela->r_addend + tls->offset;
++ break;
++ }
++ break;
+ default:
+ error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
+ (int) GELF_R_TYPE (rela->r_info));
+@@ -418,6 +560,8 @@ arm_rel_to_rela (DSO *dso, GElf_Rel *rel
+ abort ();
+ case R_ARM_RELATIVE:
+ case R_ARM_ABS32:
++ case R_ARM_TLS_TPOFF32:
++ case R_ARM_TLS_DTPOFF32:
+ rela->r_addend = (Elf32_Sword) read_ule32 (dso, rel->r_offset);
+ break;
+ case R_ARM_PC24:
+@@ -426,6 +570,7 @@ arm_rel_to_rela (DSO *dso, GElf_Rel *rel
+ break;
+ case R_ARM_COPY:
+ case R_ARM_GLOB_DAT:
++ case R_ARM_TLS_DTPMOD32:
+ rela->r_addend = 0;
+ break;
+ }
+@@ -445,6 +590,8 @@ arm_rela_to_rel (DSO *dso, GElf_Rela *re
+ abort ();
+ case R_ARM_RELATIVE:
+ case R_ARM_ABS32:
++ case R_ARM_TLS_TPOFF32:
++ case R_ARM_TLS_DTPOFF32:
+ write_le32 (dso, rela->r_offset, rela->r_addend);
+ break;
+ case R_ARM_PC24:
+@@ -453,6 +600,7 @@ arm_rela_to_rel (DSO *dso, GElf_Rela *re
+ | ((rela->r_addend >> 2) & 0xffffff));
+ break;
+ case R_ARM_GLOB_DAT:
++ case R_ARM_TLS_DTPMOD32:
+ write_le32 (dso, rela->r_offset, 0);
+ break;
+ }
+@@ -488,6 +636,15 @@ arm_need_rel_to_rela (DSO *dso, int firs
+ /* FALLTHROUGH */
+ case R_ARM_PC24:
+ return 1;
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ /* In shared libraries {D,}TPOFF32 is changed always into
++ conflicts, for executables we need to preserve
++ original addend. */
++ if (dso->ehdr.e_type == ET_EXEC) {
++ return 1;
++ }
++ break;
+ }
+ }
+ }
+@@ -612,6 +769,12 @@ arm_undo_prelink_rel (DSO *dso, GElf_Rel
+ return 0;
+ error (0, 0, "%s: R_ARM_COPY reloc in shared library?", dso->filename);
+ return 1;
++ case R_ARM_TLS_DTPMOD32:
++ write_le32 (dso, rel->r_offset, 0);
++ break;
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ break;
+ default:
+ error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
+ (int) GELF_R_TYPE (rel->r_info));
+@@ -634,6 +797,10 @@ arm_reloc_class (int reloc_type)
+ {
+ case R_ARM_COPY: return RTYPE_CLASS_COPY;
+ case R_ARM_JUMP_SLOT: return RTYPE_CLASS_PLT;
++ case R_ARM_TLS_DTPMOD32:
++ case R_ARM_TLS_DTPOFF32:
++ case R_ARM_TLS_TPOFF32:
++ return RTYPE_CLASS_TLS;
+ default: return RTYPE_CLASS_VALID;
+ }
+ }
+@@ -646,7 +813,7 @@ PL_ARCH = {
+ .R_JMP_SLOT = R_ARM_JUMP_SLOT,
+ .R_COPY = R_ARM_COPY,
+ .R_RELATIVE = R_ARM_RELATIVE,
+- .dynamic_linker = "/lib/ld-linux.so.2",
++ .dynamic_linker = "/lib/ld-linux.so.3",
+ .adjust_dyn = arm_adjust_dyn,
+ .adjust_rel = arm_adjust_rel,
+ .adjust_rela = arm_adjust_rela,
diff --git a/patches/prelink-0.0.20071009/generic/dso.c.dpatch b/patches/prelink-0.0.20071009/generic/dso.c.dpatch
new file mode 100644
index 000000000..f6b3fa7c1
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/dso.c.dpatch
@@ -0,0 +1,39 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Changed optimization level.
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+--- prelink-0.0.20030902.orig/src/dso.c 2003-08-11 11:55:11.000000000 +0000
++++ prelink-0.0.20030902/src/dso.c 2003-09-16 23:26:16.000000000 +0000
+@@ -334,7 +334,13 @@
+ }
+ else
+ sections[--k] = i;
++/* this fails for the statically linked upx executable
+ assert (j == k);
++*/
++ if (j != k) {
++ printf("assert(j == k) at dso.c:311 has failed for file %s\n", name);
++ goto error_out;
++ }
+
+ section_cmp_dso = dso;
+ qsort (sections + k, dso->ehdr.e_shnum - k, sizeof (*sections), section_cmp);
diff --git a/patches/prelink-0.0.20071009/generic/fsync.dpatch b/patches/prelink-0.0.20071009/generic/fsync.dpatch
new file mode 100644
index 000000000..9aaadc598
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/fsync.dpatch
@@ -0,0 +1,46 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Ensures to write the data on the disk when renamed a file
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -urN prelink-0.0.20060522.orig/src/cache.c prelink-0.0.20060522/src/cache.c
+--- prelink-0.0.20060522.orig/src/cache.c 2006-05-22 12:07:57.000000000 +0000
++++ prelink-0.0.20060522/src/cache.c 2006-05-24 15:18:40.000000000 +0000
+@@ -627,6 +627,7 @@
+ if (write (fd, &cache, sizeof (cache)) != sizeof (cache)
+ || write (fd, data, len) != len
+ || fchmod (fd, 0644)
++ || fsync (fd)
+ || close (fd)
+ || rename (prelink_cache_tmp, prelink_cache))
+ {
+diff -urN prelink-0.0.20060522.orig/src/dso.c prelink-0.0.20060522/src/dso.c
+--- prelink-0.0.20060522.orig/src/dso.c 2006-05-22 14:02:34.000000000 +0000
++++ prelink-0.0.20060522/src/dso.c 2006-05-24 15:19:09.000000000 +0000
+@@ -1601,6 +1601,8 @@
+ }
+
+ elf_end (dso->elf);
++ if (dso_is_rdwr (dso))
++ fsync (dso->fd);
+ close (dso->fd);
+ if (dso->elfro)
+ {
diff --git a/patches/prelink-0.0.20071009/generic/init.dpatch b/patches/prelink-0.0.20071009/generic/init.dpatch
new file mode 100644
index 000000000..7a1269ea3
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/init.dpatch
@@ -0,0 +1,86 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Adds method to re-execute /sbin/init upon change made by prelink.
+## DP: Bug#281409
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -urN prelink-0.0.20041012.orig/src/main.c prelink-0.0.20041012/src/main.c
+--- prelink-0.0.20041012.orig/src/main.c 2004-09-30 16:07:57.000000000 +0000
++++ prelink-0.0.20041012/src/main.c 2004-11-16 00:39:28.000000000 +0000
+@@ -58,6 +58,8 @@
+ const char *prelink_conf = PRELINK_CONF;
+ const char *prelink_cache = PRELINK_CACHE;
+ const char *undo_output;
++int noreexecinit;
++time_t initctime;
+
+ const char *argp_program_version = "prelink 1.0";
+
+@@ -111,6 +113,7 @@
+ {"mmap-region-end", OPT_MMAP_REG_END, "BASE_ADDRESS", OPTION_HIDDEN, "" },
+ {"seed", OPT_SEED, "SEED", OPTION_HIDDEN, "" },
+ {"compute-checksum", OPT_COMPUTE_CHECKSUM, 0, OPTION_HIDDEN, "" },
++ {"init", 'i', 0, 0, "Do not re-execute init" },
+ { 0 }
+ };
+
+@@ -222,12 +225,29 @@
+ case OPT_COMPUTE_CHECKSUM:
+ compute_checksum = 1;
+ break;
++ case 'i':
++ noreexecinit=1;
++ break;
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+ }
+
++time_t get_ctime(const char *file) {
++ struct stat st;
++ if(stat(file,&st) == 0)
++ return st.st_ctime;
++ return 0;
++}
++
++void checkinit() {
++ if(initctime != get_ctime("/sbin/init")) {
++ printf("Executing /sbin/init U\n");
++ system("/sbin/init U");
++ }
++}
++
+ static struct argp argp = { options, parse_opt, "[FILES]", argp_doc };
+
+ int
+@@ -247,6 +267,11 @@
+
+ argp_parse (&argp, argc, argv, 0, &remaining, 0);
+
++ if(!noreexecinit) {
++ initctime = get_ctime("/sbin/init");
++ atexit(checkinit);
++ }
++
+ if (ld_library_path == NULL)
+ ld_library_path = getenv ("LD_LIBRARY_PATH");
+
diff --git a/patches/prelink-0.0.20071009/generic/layout.c.dpatch b/patches/prelink-0.0.20071009/generic/layout.c.dpatch
new file mode 100644
index 000000000..a299fa146
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/layout.c.dpatch
@@ -0,0 +1,49 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Changed optimization level.
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+--- prelink-0.0.20030902.orig/src/layout.c 2003-06-13 15:12:26.000000000 +0000
++++ prelink-0.0.20030902/src/layout.c 2003-09-16 23:26:16.000000000 +0000
+@@ -614,7 +614,23 @@
+ < ((deps[j - 1]->end + max_page_size - 1)
+ & ~(max_page_size - 1))
+ && (deps[j]->type == ET_DYN || deps[j - 1]->type == ET_DYN))
++{ /* XXX some binaries cause a segfault but I do not know why -- Md*/
++ fprintf(stderr,
++ "Unknown fatal error at src/layout.c:538\n"
++ "l.binlibs[i]->filename: %s\n"
++ "deps[j]->base: %lx\n"
++ "(deps[j - 1]->end + max_page_size - 1) & ~(max_page_size - 1): %ld\n"
++ "[deps[j - 1]->end: %lx max_page_size: %lu]\n"
++ "deps[j]->type: %x deps[j - 1]->type: %x\n"
++ ,
++ l.binlibs[i]->filename,
++ deps[j]->base,
++ ((deps[j - 1]->end + max_page_size - 1) & ~(max_page_size - 1)),
++ deps[j - 1]->end, max_page_size,
++ deps[j]->type, deps[j - 1]->type
++ );
+ abort ();
++}
+ }
+ #endif
+ }
diff --git a/patches/prelink-0.0.20071009/generic/md5sha.dpatch b/patches/prelink-0.0.20071009/generic/md5sha.dpatch
new file mode 100644
index 000000000..853c4b8f1
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/md5sha.dpatch
@@ -0,0 +1,44 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Changes confusing reference to --md5 and --sha. Bug#274146
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -urN prelink-0.0.20040908.orig/doc/prelink.8 prelink-0.0.20040908/doc/prelink.8
+--- prelink-0.0.20040908.orig/doc/prelink.8 2003-08-05 08:27:59.000000000 +0000
++++ prelink-0.0.20040908/doc/prelink.8 2004-10-01 14:43:24.000000000 +0000
+@@ -173,7 +173,7 @@
+ unprobable case of modified file and original file having the same digest
+ or checksum).
+ .TP
+-.B \-\-md5
++.B \-y \-\-md5
+ This is similar to
+ .I \-\-verify
+ option, except instead of outputing the content of the binary or library
+@@ -181,7 +181,7 @@
+ See
+ .BR md5sum (1).
+ .TP
+-.B \-\-sha
++.B \-y \-\-sha
+ This is similar to
+ .I \-\-verify
+ option, except instead of outputing the content of the binary or library
diff --git a/patches/prelink-0.0.20071009/generic/prelink.h.dpatch b/patches/prelink-0.0.20071009/generic/prelink.h.dpatch
new file mode 100644
index 000000000..33bc9869a
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/prelink.h.dpatch
@@ -0,0 +1,71 @@
+#! /bin/sh -e
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Changed optimization level.
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+--- prelink-0.0.20030902.orig/src/prelink.h 2003-08-11 11:54:01.000000000 +0000
++++ prelink-0.0.20030902/src/prelink.h 2003-09-16 23:26:16.000000000 +0000
+@@ -26,6 +26,45 @@
+ #include <stdio.h>
+ #include <sys/stat.h>
+
++/* http://gcc.gnu.org/ml/gcc/2003-01/msg00922.html */
++#ifndef R_390_TLS_DTPMOD
++#define R_390_TLS_DTPMOD 54
++#define R_390_TLS_DTPOFF 55
++#define R_390_TLS_TPOFF 56
++#endif
++
++/* from http://www.cygwin.com/ml/libc-alpha/2003-02/msg00241.html */
++#ifndef R_PPC_TLS
++#define R_PPC_TLS 67
++#define R_PPC_DTPMOD32 68
++#define R_PPC_TPREL16 69
++#define R_PPC_TPREL16_LO 70
++#define R_PPC_TPREL16_HI 71
++#define R_PPC_TPREL16_HA 72
++#define R_PPC_TPREL32 73
++#define R_PPC_DTPREL16 74
++#define R_PPC_DTPREL16_LO 75
++#define R_PPC_DTPREL16_HI 76
++#define R_PPC_DTPREL16_HA 77
++#define R_PPC_DTPREL32 78
++#define R_PPC_GOT_TLSGD16 79
++#define R_PPC_GOT_TLSGD16_LO 80
++#define R_PPC_GOT_TLSGD16_HI 81
++#define R_PPC_GOT_TLSGD16_HA 82
++#define R_PPC_GOT_TLSLD16 83
++#define R_PPC_GOT_TLSLD16_LO 84
++#define R_PPC_GOT_TLSLD16_HI 85
++#define R_PPC_GOT_TLSLD16_HA 86
++#define R_PPC_GOT_TPREL16 87
++#define R_PPC_GOT_TPREL16_LO 88
++#define R_PPC_GOT_TPREL16_HI 89
++#define R_PPC_GOT_TPREL16_HA 90
++#define R_PPC_GOT_DTPREL16 91
++#define R_PPC_GOT_DTPREL16_LO 92
++#define R_PPC_GOT_DTPREL16_HI 93
++#define R_PPC_GOT_DTPREL16_HA 94
++#endif
++
+ #ifndef DT_GNU_LIBLIST
+ #define DT_GNU_LIBLIST 0x6ffffef9
+ #define DT_GNU_LIBLISTSZ 0x6ffffdf7
diff --git a/patches/prelink-0.0.20071009/generic/series b/patches/prelink-0.0.20071009/generic/series
new file mode 100644
index 000000000..a43cbb41c
--- /dev/null
+++ b/patches/prelink-0.0.20071009/generic/series
@@ -0,0 +1,7 @@
+dso.c.dpatch
+fsync.dpatch
+init.dpatch
+layout.c.dpatch
+Makefile.in.dpatch
+md5sha.dpatch
+prelink.h.dpatch