summaryrefslogtreecommitdiffstats
path: root/meta/packages/prelink
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-12-19 19:24:24 +0000
committerRichard Purdie <richard@openedhand.com>2006-12-19 19:24:24 +0000
commita8b7d094ed0686b0f6737861e0d82224acedfacc (patch)
tree2f42907c9349b3a79719f15a0d56aa4cdfa1b47a /meta/packages/prelink
parent01303ccecf5e0cc24fdd1a67071d1cfd9ead545e (diff)
downloadpoky-a8b7d094ed0686b0f6737861e0d82224acedfacc.tar.gz
Add elfutils, prelink
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1049 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/prelink')
-rw-r--r--meta/packages/prelink/prelink-20061027/arm_eabi.patch286
-rw-r--r--meta/packages/prelink/prelink-20061027/prelink.conf18
-rw-r--r--meta/packages/prelink/prelink-20061027/prelink.cron.daily40
-rw-r--r--meta/packages/prelink/prelink-20061027/prelink.default22
-rw-r--r--meta/packages/prelink/prelink_20061027.bb46
5 files changed, 412 insertions, 0 deletions
diff --git a/meta/packages/prelink/prelink-20061027/arm_eabi.patch b/meta/packages/prelink/prelink-20061027/arm_eabi.patch
new file mode 100644
index 0000000000..b234af9b3f
--- /dev/null
+++ b/meta/packages/prelink/prelink-20061027/arm_eabi.patch
@@ -0,0 +1,286 @@
1Index: prelink-0.0.20050901/src/arch-arm.c
2===================================================================
3--- prelink-0.0.20050901.orig/src/arch-arm.c 2004-09-30 17:07:57.000000000 +0100
4+++ prelink-0.0.20050901/src/arch-arm.c 2006-04-07 14:41:25.000000000 +0100
5@@ -145,6 +145,24 @@
6 error (0, 0, "%s: R_ARM_PC24 relocs with non-zero addend should not be present in prelinked REL sections",
7 dso->filename);
8 return 1;
9+ case R_ARM_TLS_DTPOFF32:
10+ write_le32 (dso, rel->r_offset, value);
11+ break;
12+ /* DTPMOD32 and TPOFF32 is impossible to predict unless prelink
13+ sets the rules. Also for TPOFF{32,} there is REL->RELA problem. */
14+ case R_ARM_TLS_DTPMOD32:
15+ if (dso->ehdr.e_type == ET_EXEC)
16+ {
17+ error (0, 0, "%s: R_ARM_TLS_DTPMOD32 reloc in executable?",
18+ dso->filename);
19+ return 1;
20+ }
21+ break;
22+ case R_ARM_TLS_TPOFF32:
23+ if (dso->ehdr.e_type == ET_EXEC)
24+ error (0, 0, "%s: R_ARM_TLS_TPOFF32 relocs should not be present in prelinked ET_EXEC REL sections",
25+ dso->filename);
26+ break;
27 case R_ARM_COPY:
28 if (dso->ehdr.e_type == ET_EXEC)
29 /* COPY relocs are handled specially in generic code. */
30@@ -195,6 +213,24 @@
31 write_le32 (dso, rela->r_offset,
32 (read_ule32 (dso, rela->r_offset) & 0xff000000) | val);
33 break;
34+ case R_ARM_TLS_DTPOFF32:
35+ write_le32 (dso, rela->r_offset, value + rela->r_addend);
36+ break;
37+ /* DTPMOD32 and TPOFF32 is impossible to predict unless prelink
38+ sets the rules. */
39+ case R_ARM_TLS_DTPMOD32:
40+ if (dso->ehdr.e_type == ET_EXEC)
41+ {
42+ error (0, 0, "%s: R_ARM_TLS_DTPMOD32 reloc in executable?",
43+ dso->filename);
44+ return 1;
45+ }
46+ break;
47+ case R_ARM_TLS_TPOFF32:
48+ if (dso->ehdr.e_type == ET_EXEC && info->resolvetls)
49+ write_le32 (dso, rela->r_offset,
50+ -(value + rela->r_addend - info->resolvetls->offset));
51+ break;
52 case R_ARM_COPY:
53 if (dso->ehdr.e_type == ET_EXEC)
54 /* COPY relocs are handled specially in generic code. */
55@@ -315,6 +351,7 @@
56 {
57 GElf_Addr value;
58 struct prelink_conflict *conflict;
59+ struct prelink_tls *tls;
60 GElf_Rela *ret;
61
62 if (GELF_R_TYPE (rel->r_info) == R_ARM_RELATIVE
63@@ -324,8 +361,31 @@
64 conflict = prelink_conflict (info, GELF_R_SYM (rel->r_info),
65 GELF_R_TYPE (rel->r_info));
66 if (conflict == NULL)
67- return 0;
68- value = conflict_lookup_value (conflict);
69+ {
70+ if (info->curtls == NULL)
71+ return 0;
72+ switch (GELF_R_TYPE (rel->r_info))
73+ {
74+ /* Even local DTPMOD and TPOFF relocs need conflicts. */
75+ case R_ARM_TLS_DTPMOD32:
76+ case R_ARM_TLS_TPOFF32:
77+ break;
78+ default:
79+ return 0;
80+ }
81+ value = 0;
82+ }
83+ else
84+ {
85+ /* DTPOFF32 wants to see only real conflicts, not lookups
86+ with reloc_class RTYPE_CLASS_TLS. */
87+ if (GELF_R_TYPE (rel->r_info) == R_ARM_TLS_DTPOFF32
88+ && conflict->lookup.tls == conflict->conflict.tls
89+ && conflict->lookupval == conflict->conflictval)
90+ return 0;
91+
92+ value = conflict_lookup_value (conflict);
93+ }
94 ret = prelink_conflict_add_rela (info);
95 if (ret == NULL)
96 return 1;
97@@ -342,6 +402,33 @@
98 error (0, 0, "%s: R_ARM_%s relocs should not be present in prelinked REL sections",
99 dso->filename, GELF_R_TYPE (rel->r_info) == R_ARM_ABS32 ? "ABS32" : "PC24");
100 return 1;
101+ case R_ARM_TLS_DTPMOD32:
102+ case R_ARM_TLS_DTPOFF32:
103+ case R_ARM_TLS_TPOFF32:
104+ if (conflict != NULL
105+ && (conflict->reloc_class != RTYPE_CLASS_TLS
106+ || conflict->lookup.tls == NULL))
107+ {
108+ error (0, 0, "%s: R_ARM_TLS not resolving to STT_TLS symbol",
109+ dso->filename);
110+ return 1;
111+ }
112+ tls = conflict ? conflict->lookup.tls : info->curtls;
113+ ret->r_info = GELF_R_INFO (0, R_ARM_ABS32);
114+ switch (GELF_R_TYPE (rel->r_info))
115+ {
116+ case R_ARM_TLS_DTPMOD32:
117+ ret->r_addend = tls->modid;
118+ break;
119+ case R_ARM_TLS_DTPOFF32:
120+ ret->r_addend = value;
121+ break;
122+ case R_ARM_TLS_TPOFF32:
123+ ret->r_addend = -(value + read_ule32 (dso, rel->r_offset)
124+ - tls->offset);
125+ break;
126+ }
127+ break;
128 case R_ARM_COPY:
129 error (0, 0, "R_ARM_COPY should not be present in shared libraries");
130 return 1;
131@@ -359,6 +446,7 @@
132 {
133 GElf_Addr value;
134 struct prelink_conflict *conflict;
135+ struct prelink_tls *tls;
136 GElf_Rela *ret;
137 Elf32_Sword val;
138
139@@ -369,8 +457,31 @@
140 conflict = prelink_conflict (info, GELF_R_SYM (rela->r_info),
141 GELF_R_TYPE (rela->r_info));
142 if (conflict == NULL)
143- return 0;
144- value = conflict_lookup_value (conflict);
145+ {
146+ if (info->curtls == NULL)
147+ return 0;
148+ switch (GELF_R_TYPE (rela->r_info))
149+ {
150+ /* Even local DTPMOD and TPOFF relocs need conflicts. */
151+ case R_ARM_TLS_DTPMOD32:
152+ case R_ARM_TLS_TPOFF32:
153+ break;
154+ default:
155+ return 0;
156+ }
157+ value = 0;
158+ }
159+ else
160+ {
161+ /* DTPOFF32 wants to see only real conflicts, not lookups
162+ with reloc_class RTYPE_CLASS_TLS. */
163+ if (GELF_R_TYPE (rela->r_info) == R_ARM_TLS_DTPOFF32
164+ && conflict->lookup.tls == conflict->conflict.tls
165+ && conflict->lookupval == conflict->conflictval)
166+ return 0;
167+
168+ value = conflict_lookup_value (conflict);
169+ }
170 ret = prelink_conflict_add_rela (info);
171 if (ret == NULL)
172 return 1;
173@@ -398,6 +509,32 @@
174 case R_ARM_COPY:
175 error (0, 0, "R_ARM_COPY should not be present in shared libraries");
176 return 1;
177+ case R_ARM_TLS_DTPMOD32:
178+ case R_ARM_TLS_DTPOFF32:
179+ case R_ARM_TLS_TPOFF32:
180+ if (conflict != NULL
181+ && (conflict->reloc_class != RTYPE_CLASS_TLS
182+ || conflict->lookup.tls == NULL))
183+ {
184+ error (0, 0, "%s: R_386_TLS not resolving to STT_TLS symbol",
185+ dso->filename);
186+ return 1;
187+ }
188+ tls = conflict ? conflict->lookup.tls : info->curtls;
189+ ret->r_info = GELF_R_INFO (0, R_ARM_ABS32);
190+ switch (GELF_R_TYPE (rela->r_info))
191+ {
192+ case R_ARM_TLS_DTPMOD32:
193+ ret->r_addend = tls->modid;
194+ break;
195+ case R_ARM_TLS_DTPOFF32:
196+ ret->r_addend += value;
197+ break;
198+ case R_ARM_TLS_TPOFF32:
199+ ret->r_addend = -(value + rela->r_addend - tls->offset);
200+ break;
201+ }
202+ break;
203 default:
204 error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
205 (int) GELF_R_TYPE (rela->r_info));
206@@ -418,6 +555,7 @@
207 abort ();
208 case R_ARM_RELATIVE:
209 case R_ARM_ABS32:
210+ case R_ARM_TLS_TPOFF32:
211 rela->r_addend = (Elf32_Sword) read_ule32 (dso, rel->r_offset);
212 break;
213 case R_ARM_PC24:
214@@ -426,6 +564,8 @@
215 break;
216 case R_ARM_COPY:
217 case R_ARM_GLOB_DAT:
218+ case R_ARM_TLS_DTPOFF32:
219+ case R_ARM_TLS_DTPMOD32:
220 rela->r_addend = 0;
221 break;
222 }
223@@ -445,6 +585,7 @@
224 abort ();
225 case R_ARM_RELATIVE:
226 case R_ARM_ABS32:
227+ case R_ARM_TLS_TPOFF32:
228 write_le32 (dso, rela->r_offset, rela->r_addend);
229 break;
230 case R_ARM_PC24:
231@@ -453,6 +594,8 @@
232 | ((rela->r_addend >> 2) & 0xffffff));
233 break;
234 case R_ARM_GLOB_DAT:
235+ case R_ARM_TLS_DTPMOD32:
236+ case R_ARM_TLS_DTPOFF32:
237 write_le32 (dso, rela->r_offset, 0);
238 break;
239 }
240@@ -488,6 +631,13 @@
241 /* FALLTHROUGH */
242 case R_ARM_PC24:
243 return 1;
244+ case R_ARM_TLS_TPOFF32:
245+ /* In shared libraries TPOFF is changed always into
246+ conflicts, for executables we need to preserve
247+ original addend. */
248+ if (dso->ehdr.e_type == ET_EXEC)
249+ return 1;
250+ break;
251 }
252 }
253 }
254@@ -612,6 +762,12 @@
255 return 0;
256 error (0, 0, "%s: R_ARM_COPY reloc in shared library?", dso->filename);
257 return 1;
258+ case R_ARM_TLS_DTPMOD32:
259+ case R_ARM_TLS_DTPOFF32:
260+ write_le32 (dso, rel->r_offset, 0);
261+ break;
262+ case R_ARM_TLS_TPOFF32:
263+ break;
264 default:
265 error (0, 0, "%s: Unknown arm relocation type %d", dso->filename,
266 (int) GELF_R_TYPE (rel->r_info));
267@@ -634,6 +790,10 @@
268 {
269 case R_ARM_COPY: return RTYPE_CLASS_COPY;
270 case R_ARM_JUMP_SLOT: return RTYPE_CLASS_PLT;
271+ case R_ARM_TLS_DTPMOD32:
272+ case R_ARM_TLS_DTPOFF32:
273+ case R_ARM_TLS_TPOFF32:
274+ return RTYPE_CLASS_TLS;
275 default: return RTYPE_CLASS_VALID;
276 }
277 }
278@@ -646,7 +806,7 @@
279 .R_JMP_SLOT = R_ARM_JUMP_SLOT,
280 .R_COPY = R_ARM_COPY,
281 .R_RELATIVE = R_ARM_RELATIVE,
282- .dynamic_linker = "/lib/ld-linux.so.2",
283+ .dynamic_linker = "/lib/ld-linux.so.3",
284 .adjust_dyn = arm_adjust_dyn,
285 .adjust_rel = arm_adjust_rel,
286 .adjust_rela = arm_adjust_rela,
diff --git a/meta/packages/prelink/prelink-20061027/prelink.conf b/meta/packages/prelink/prelink-20061027/prelink.conf
new file mode 100644
index 0000000000..c5a4f4adc3
--- /dev/null
+++ b/meta/packages/prelink/prelink-20061027/prelink.conf
@@ -0,0 +1,18 @@
1# This config file contains a list of directories both with binaries
2# and libraries prelink should consider by default.
3# If a directory name is prefixed with `-l ', the directory hierarchy
4# will be walked as long as filesystem boundaries are not crossed.
5# If a directory name is prefixed with `-h ', symbolic links in a
6# directory hierarchy are followed.
7-l /usr/local/sbin
8-l /sbin
9-l /usr/sbin
10-l /usr/local/bin
11-l /bin
12-l /usr/bin
13-l /usr/X11R6/bin
14-l /usr/games
15-l /usr/local/lib
16-l /lib
17-l /usr/lib
18-l /usr/X11R6/lib
diff --git a/meta/packages/prelink/prelink-20061027/prelink.cron.daily b/meta/packages/prelink/prelink-20061027/prelink.cron.daily
new file mode 100644
index 0000000000..0b3c07322c
--- /dev/null
+++ b/meta/packages/prelink/prelink-20061027/prelink.cron.daily
@@ -0,0 +1,40 @@
1#!/bin/sh
2
3. /etc/default/prelink
4
5renice +19 -p $$ >/dev/null 2>&1
6
7if [ "$PRELINKING" != yes ]; then
8 if [ -f /etc/prelink.cache ]; then
9 echo /usr/sbin/prelink -uav > /var/log/prelink.log
10 /usr/sbin/prelink -uav >> /var/log/prelink.log 2>&1
11 rm -f /etc/prelink.cache
12 # Restart init if needed
13 [ -n "$(find `ldd /sbin/init | awk '{ print $3 }'` /sbin/init -ctime -1 2>/dev/null )" ] && /sbin/telinit u
14 fi
15 exit 0
16fi
17
18if [ ! -f /etc/prelink.cache -o -f /var/lib/misc/prelink.force ] \
19 || grep -q '^prelink-ELF0.[0-2]' /etc/prelink.cache; then
20 # If cache does not exist or is from older prelink versions or
21 # if we were asked to explicitely, force full prelinking
22 rm -f /etc/prelink.cache /var/lib/misc/prelink.force
23 PRELINK_OPTS="$PRELINK_OPTS -f"
24 date > /var/lib/misc/prelink.full
25elif [ -n "$PRELINK_FULL_TIME_INTERVAL" \
26 -a "`find /var/lib/misc/prelink.full -mtime -${PRELINK_FULL_TIME_INTERVAL} 2>/dev/null`" \
27 = /var/lib/misc/prelink.full ]; then
28 # If prelink without -q has been run in the last
29 # PRELINK_FULL_TIME_INTERVAL days, just use quick mode
30 PRELINK_OPTS="$PRELINK_OPTS -q"
31else
32 date > /var/lib/misc/prelink.full
33fi
34
35echo /usr/sbin/prelink -av $PRELINK_OPTS > /var/log/prelink.log
36/usr/sbin/prelink -av $PRELINK_OPTS >> /var/log/prelink.log 2>&1
37# Restart init if needed
38[ -n "$(find `ldd /sbin/init | awk '{ print $3 }'` /sbin/init -ctime -1 2>/dev/null )" ] && /sbin/telinit u
39
40exit 0
diff --git a/meta/packages/prelink/prelink-20061027/prelink.default b/meta/packages/prelink/prelink-20061027/prelink.default
new file mode 100644
index 0000000000..901258ed2a
--- /dev/null
+++ b/meta/packages/prelink/prelink-20061027/prelink.default
@@ -0,0 +1,22 @@
1# Set this to no to disable prelinking altogether
2# or to yes to enable it.
3# (if you change this from yes to no prelink -ua
4# will be run next night to undo prelinking)
5PRELINKING=unknown
6
7# Options to pass to prelink
8# -m Try to conserve virtual memory by allowing overlapping
9# assigned virtual memory slots for libraries which
10# never appear together in one binary
11# -R Randomize virtual memory slot assignments for libraries.
12# This makes it slightly harder for various buffer overflow
13# attacks, since library addresses will be different on each
14# host using -R.
15PRELINK_OPTS=-mR
16
17# How often should full prelink be run (in days)
18# Normally, prelink will be run in quick mode, every
19# $PRELINK_FULL_TIME_INTERVAL days it will be run
20# in normal mode. Comment this line out if prelink
21# should be run in normal mode always.
22PRELINK_FULL_TIME_INTERVAL=14
diff --git a/meta/packages/prelink/prelink_20061027.bb b/meta/packages/prelink/prelink_20061027.bb
new file mode 100644
index 0000000000..a83ff1b61f
--- /dev/null
+++ b/meta/packages/prelink/prelink_20061027.bb
@@ -0,0 +1,46 @@
1SECTION = "devel"
2DEPENDS = "elfutils"
3DESCRIPTION = " The prelink package contains a utility which modifies ELF shared libraries \
4and executables, so that far fewer relocations need to be resolved at \
5runtime and thus programs come up faster."
6LICENSE = "GPL"
7PR = "r2"
8
9SRC_URI = "${DEBIAN_MIRROR}/main/p/prelink/prelink_0.0.${PV}.orig.tar.gz \
10 file://prelink.conf \
11 file://prelink.cron.daily \
12 file://prelink.default"
13
14TARGET_OS_ORIG := "${TARGET_OS}"
15OVERRIDES_append = ":${TARGET_OS_ORIG}"
16SRC_URI_append_linux-gnueabi = " file://arm_eabi.patch;patch=1"
17
18S = "${WORKDIR}/prelink-0.0.${PV}"
19
20EXTRA_OECONF = "--disable-64bit"
21
22inherit autotools
23
24do_install_append () {
25 install -d ${D}${sysconfdir}/cron.daily ${D}${sysconfdir}/default
26 install -m 0644 ${WORKDIR}/prelink.conf ${D}${sysconfdir}/prelink.conf
27 install -m 0644 ${WORKDIR}/prelink.cron.daily ${D}${sysconfdir}/cron.daily/prelink
28 install -m 0644 ${WORKDIR}/prelink.default ${D}${sysconfdir}/default/prelink
29}
30
31pkg_postinst_prelink() {
32#!/bin/sh
33
34if [ "x$D" != "x" ]; then
35 exit 1
36fi
37
38prelink -a
39}
40
41pkg_postrm_prelink() {
42#!/bin/sh
43
44prelink -au
45}
46