summaryrefslogtreecommitdiff
path: root/openembedded/packages/glibc/glibc-cvs/trampoline.patch
blob: 86cfc0a5390b2703258b204f2e4ec1a1000a1898 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
From libc-alpha-return-16890-listarch-libc-alpha=sources dot redhat dot com at sources dot redhat dot com Wed Jan 19 18:02:53 2005
Return-Path: <libc-alpha-return-16890-listarch-libc-alpha=sources dot redhat dot com at sources dot redhat dot com>
Delivered-To: listarch-libc-alpha at sources dot redhat dot com
Received: (qmail 26073 invoked by alias); 19 Jan 2005 18:02:41 -0000
Mailing-List: contact libc-alpha-help at sources dot redhat dot com; run by ezmlm
Precedence: bulk
List-Subscribe: <mailto:libc-alpha-subscribe at sources dot redhat dot com>
List-Archive: <http://sources.redhat.com/ml/libc-alpha/>
List-Post: <mailto:libc-alpha at sources dot redhat dot com>
List-Help: <mailto:libc-alpha-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs>
Sender: libc-alpha-owner at sources dot redhat dot com
Delivered-To: mailing list libc-alpha at sources dot redhat dot com
Received: (qmail 25420 invoked from network); 19 Jan 2005 18:01:47 -0000
Received: from unknown (HELO mail.codesourcery.com) (65.74.133.9)
  by sourceware dot org with SMTP; 19 Jan 2005 18:01:47 -0000
Received: (qmail 7456 invoked from network); 19 Jan 2005 18:01:44 -0000
Received: from localhost (HELO ?192.168.0.100?) (mitchell@127.0.0.1)
  by mail dot codesourcery dot com with SMTP; 19 Jan 2005 18:01:44 -0000
Message-ID: <41EEA082.1020000@codesourcery.com>
Date: Wed, 19 Jan 2005 10:01:38 -0800
From: Mark Mitchell <mark at codesourcery dot com>
Organization: CodeSourcery, LLC
User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103)
MIME-Version: 1.0
To: Daniel Jacobowitz <drow at false dot org>
CC:  libc-alpha at sources dot redhat dot com
Subject: Re: PATCH: ARM dl-trampoline.S
References: <200501191631.j0JGVVRA002591@sirius.codesourcery.com> <20050119170217.GA3137@nevyn.them.org>
In-Reply-To: <20050119170217 dot GA3137 at nevyn dot them dot org>
Content-Type: multipart/mixed;
 boundary="------------050601050507020101060100"

This is a multi-part message in MIME format.
--------------050601050507020101060100
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Daniel Jacobowitz wrote:
> On Wed, Jan 19, 2005 at 08:31:31AM -0800, Mark Mitchell wrote:
> 
>>This patch updates the ARM port for the recent dl-trampoline.S and
>>link.h changes.  OK to apply?
> 
> 
> Did you test this?  I'm pretty sure that RESOLVE_MAP returns a link
> map, unlike RESOLVE.

No, I didn't test -- except by building glibc.  (There are other 
problems at the moment, AFAICT, with actually running the library on ARM.)

However, you're definitely correct -- good catch! -- and, in fact, in 
looking at my logs I see compiler warnings about the mismatched type 
assignment.  Here is a more plausible version.  How about this one?

Thanks,

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304

--------------050601050507020101060100
Content-Type: text/plain;
 name="glibc.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="glibc.patch"

2005-01-19  Mark Mitchell  <mark@codesourcery.com>

	* elf/tst-auditmod1.c: Add ARM support.
	* sysdeps/arm/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
	Remove.
	(RESOLVE): Do not use it; use ...
	(RESOLVE_MAP): ... instead.
	(ARCH_LA_PLTENTER): Define.
	(ARCH_LA_PLTEXIT): Likewise.
	(elf_machine_rel): Use RESOLVE_MAP, not RESOLVE.
	(elf_machine_rela): Likewise.
	* sysdeps/arm/dl-trampoline.S: New file.
	* sysdeps/arm/bits/link.h: Likewise.
	* sysdeps/generic/ldsodefs.h (struct La_arm_regs): Declare.
	(struct audit_ifaces): Add ARM functions.

Index: elf/tst-auditmod1.c
===================================================================
RCS file: /cvs/glibc/libc/elf/tst-auditmod1.c,v
retrieving revision 1.7
diff -c -5 -p -r1.7 tst-auditmod1.c
*** elf/tst-auditmod1.c	16 Jan 2005 06:24:59 -0000	1.7
--- elf/tst-auditmod1.c	19 Jan 2005 17:54:32 -0000
*************** la_symbind64 (Elf64_Sym *sym, unsigned i
*** 100,110 ****
  	  symname, (long int) sym->st_value, ndx, *flags);
  
    return sym->st_value;
  }
  
! #ifdef __i386__
  # define pltenter la_i86_gnu_pltenter
  # define pltexit la_i86_gnu_pltexit
  # define La_regs La_i86_regs
  # define La_retval La_i86_retval
  # define int_retval lrv_eax
--- 100,116 ----
  	  symname, (long int) sym->st_value, ndx, *flags);
  
    return sym->st_value;
  }
  
! #ifdef __arm__
! # define pltenter la_arm_gnu_plteneter
! # define pltext la_arm_gnu_pltexit
! # define La_regs La_arm_regs
! # define La_retval La_arm_retval
! # define int_retval lvr_r0
! #elif defined __i386__
  # define pltenter la_i86_gnu_pltenter
  # define pltexit la_i86_gnu_pltexit
  # define La_regs La_i86_regs
  # define La_retval La_i86_retval
  # define int_retval lrv_eax
Index: sysdeps/arm/dl-trampoline.S
===================================================================
RCS file: sysdeps/arm/dl-trampoline.S
diff -N sysdeps/arm/dl-trampoline.S
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- sysdeps/arm/dl-trampoline.S	19 Jan 2005 17:54:32 -0000
***************
*** 0 ****
--- 1,135 ----
+ /* PLT trampolines.  ARM version.
+    Copyright (C) 2005 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+ 
+    The GNU C Library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+ 
+    You should have received a copy of the GNU Lesser General Public
+    License along with the GNU C Library; if not, write to the Free
+    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+    02111-1307 USA.  */
+ 
+ #include <sysdep.h>
+ 
+ #if defined(__USE_BX__)
+ #define BX(x) bx	x
+ #else
+ #define BX(x) mov	pc, x
+ #endif
+ 
+ #ifndef PROF
+ 	.text
+ 	.globl _dl_runtime_resolve
+ 	.type _dl_runtime_resolve, #function
+ 	.align 2
+ _dl_runtime_resolve:
+ 	@ we get called with
+ 	@ 	stack[0] contains the return address from this call
+ 	@	ip contains &GOT[n+3] (pointer to function)
+ 	@	lr points to &GOT[2]
+ 
+ 	@ stack arguments
+ 	stmdb	sp!,{r0-r3}
+ 
+ 	@ get pointer to linker struct
+ 	ldr	r0, [lr, #-4]
+ 
+ 	@ prepare to call _dl_fixup()
+ 	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
+ 	sub	r1, ip, lr
+ 	sub	r1, r1, #4
+ 	add	r1, r1, r1
+ 
+ 	@ call fixup routine
+ 	bl	_dl_fixup
+ 
+ 	@ save the return
+ 	mov	ip, r0
+ 
+ 	@ get arguments and return address back
+ 	ldmia	sp!, {r0-r3,lr}
+ 
+ 	@ jump to the newly found address
+ 	BX(ip)
+ 
+ 	.size _dl_runtime_resolve, .-_dl_runtime_resolve
+ 
+ 	.globl _dl_runtime_profile
+ 	.type _dl_runtime_profile, #function
+ 	.align 2
+ _dl_runtime_profile:
+ 	@ stack arguments
+ 	stmdb	sp!, {r0-r3}
+ 
+ 	@ get pointer to linker struct
+ 	ldr	r0, [lr, #-4]
+ 
+ 	@ prepare to call _dl_profile_fixup()
+ 	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
+ 	sub	r1, ip, lr
+ 	sub	r1, r1, #4
+ 	add	r1, r1, r1
+ 
+ 	@ call profiling fixup routine
+ 	bl	_dl_profile_fixup
+ 
+ 	@ save the return
+ 	mov	ip, r0
+ 
+ 	@ get arguments and return address back
+ 	ldmia	sp!, {r0-r3,lr}
+ 
+ 	@ jump to the newly found address
+ 	BX(ip)
+ 
+ 	.size _dl_runtime_resolve, .-_dl_runtime_resolve
+ 	.previous
+ #else
+ 	.text
+ 	.globl _dl_runtime_resolve
+ 	.globl _dl_runtime_profile
+ 	.type _dl_runtime_resolve, #function
+ 	.type _dl_runtime_profile, #function
+ 	.align 2
+ _dl_runtime_resolve:
+ _dl_runtime_profile:
+ 	@ we get called with
+ 	@ 	stack[0] contains the return address from this call
+ 	@	ip contains &GOT[n+3] (pointer to function)
+ 	@	lr points to &GOT[2]
+ 
+ 	@ stack arguments
+ 	stmdb	sp!, {r0-r3}
+ 
+ 	@ get pointer to linker struct
+ 	ldr	r0, [lr, #-4]
+ 
+ 	@ prepare to call _dl_fixup()
+ 	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each
+ 	sub	r1, ip, lr
+ 	sub	r1, r1, #4
+ 	add	r1, r1, r1
+ 
+ 	@ call profiling fixup routine
+ 	bl	_dl_fixup
+ 
+ 	@ save the return
+ 	mov	ip, r0
+ 
+ 	@ get arguments and return address back
+ 	ldmia	sp!, {r0-r3,lr}
+ 
+ 	@ jump to the newly found address
+ 	BX(ip)
+ 
+ 	.size _dl_runtime_profile, .-_dl_runtime_profile
+ 	.previous
+ #endif
Index: sysdeps/arm/bits/link.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/arm/bits/link.h,v
retrieving revision 1.2
diff -c -5 -p -r1.2 link.h
*** sysdeps/arm/bits/link.h	6 Jan 2005 22:40:20 -0000	1.2
--- sysdeps/arm/bits/link.h	19 Jan 2005 17:54:32 -0000
***************
*** 0 ****
--- 1,57 ----
+ /* Copyright (C) 2005 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+ 
+    The GNU C Library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+ 
+    You should have received a copy of the GNU Lesser General Public
+    License along with the GNU C Library; if not, write to the Free
+    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+    02111-1307 USA.  */
+ 
+ #ifndef	_LINK_H
+ # error "Never include <bits/link.h> directly; use <link.h> instead."
+ #endif
+ 
+ 
+ /* Registers for entry into PLT on ARM.  */
+ typedef struct La_arm_regs
+ {
+   uint32_t lvr_r0;
+   uint32_t lvr_r1;
+   uint32_t lvr_r2;
+   uint32_t lvr_r3;
+ } La_arm_regs;
+ 
+ /* Return values for calls from PLT on ARM.  */
+ typedef struct La_arm_retval
+ {
+   uint32_t lvr_r0;
+   uint32_t lvr_r1;
+ } La_arm_retval;
+ 
+ 
+ __BEGIN_DECLS
+ 
+ extern Elf32_Addr la_arm_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ 				       uintptr_t *__refcook,
+ 				       uintptr_t *__defcook,
+ 				       La_arm_regs *__regs,
+ 				       unsigned int *__flags,
+ 				       const char *__symname,
+ 				       long int *__framesizep);
+ extern unsigned int la_arm_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ 					uintptr_t *__refcook,
+ 					uintptr_t *__defcook,
+ 					const La_arm_regs *__inregs,
+ 					La_arm_retval *__outregs,
+ 					const char *symname);
+ 
+ __END_DECLS
Index: sysdeps/generic/ldsodefs.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/generic/ldsodefs.h,v
retrieving revision 1.112
diff -c -5 -p -r1.112 ldsodefs.h
*** sysdeps/generic/ldsodefs.h	16 Jan 2005 02:07:29 -0000	1.112
--- sysdeps/generic/ldsodefs.h	19 Jan 2005 17:54:32 -0000
*************** enum allowmask
*** 173,182 ****
--- 173,183 ----
      allow_ldso = 8
    };
  
  
  /* Type for list of auditing interfaces.  */
+ struct La_arm_regs;
  struct La_i86_regs;
  struct La_i86_retval;
  struct La_x86_64_regs;
  struct La_x86_64_retval;
  struct La_ppc32_regs;
*************** struct audit_ifaces
*** 202,211 ****
--- 203,216 ----
      uintptr_t (*symbind64) (Elf64_Sym *, unsigned int, uintptr_t *,
  			    uintptr_t *, unsigned int *, const char *);
    };
    union
    {
+     Elf32_Addr (*arm_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *,
+ 				    uintptr_t *, struct La_arm_regs *,
+ 				    unsigned int *, const char *name,
+ 				    long int *framesizep);
      Elf32_Addr (*i86_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *,
  				    uintptr_t *, struct La_i86_regs *,
  				    unsigned int *, const char *name,
  				    long int *framesizep);
      Elf64_Addr (*x86_64_gnu_pltenter) (Elf64_Sym *, unsigned int, uintptr_t *,
*************** struct audit_ifaces
*** 229,238 ****
--- 234,246 ----
  				     unsigned int *, const char *name,
  				     long int *framesizep);
    };
    union
    {
+     unsigned int (*arm_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *,
+ 				     uintptr_t *, const struct La_arm_regs *,
+ 				     struct La_i86_retval *, const char *);
      unsigned int (*i86_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *,
  				     uintptr_t *, const struct La_i86_regs *,
  				     struct La_i86_retval *, const char *);
      unsigned int (*x86_64_gnu_pltexit) (Elf64_Sym *, unsigned int, uintptr_t *,
  					uintptr_t *,

--------------050601050507020101060100--

diff -u -r1.52 dl-machine.h
--- sysdeps/arm/dl-machine.h	15 Mar 2005 22:57:26 -0000	1.52
+++ sysdeps/arm/dl-machine.h	22 Apr 2005 03:38:15 -0000
@@ -129,119 +129,6 @@
 #define BX(x) "mov\tpc, " #x
 #endif
 
-#ifndef PROF
-# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
-	.text\n\
-	.globl _dl_runtime_resolve\n\
-	.type _dl_runtime_resolve, #function\n\
-	.align 2\n\
-_dl_runtime_resolve:\n\
-	@ we get called with\n\
-	@ 	stack[0] contains the return address from this call\n\
-	@	ip contains &GOT[n+3] (pointer to function)\n\
-	@	lr points to &GOT[2]\n\
-\n\
-	@ stack arguments\n\
-	stmdb	sp!,{r0-r3}\n\
-\n\
-	@ get pointer to linker struct\n\
-	ldr	r0, [lr, #-4]\n\
-\n\
-	@ prepare to call fixup()\n\
-	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
-	sub	r1, ip, lr\n\
-	sub	r1, r1, #4\n\
-	add	r1, r1, r1\n\
-\n\
-	@ call fixup routine\n\
-	bl	fixup\n\
-\n\
-	@ save the return\n\
-	mov	ip, r0\n\
-\n\
-	@ get arguments and return address back\n\
-	ldmia	sp!, {r0-r3,lr}\n\
-\n\
-	@ jump to the newly found address\n\
-	" BX(ip) "\n\
-\n\
-	.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
-\n\
-	.globl _dl_runtime_profile\n\
-	.type _dl_runtime_profile, #function\n\
-	.align 2\n\
-_dl_runtime_profile:\n\
-	@ stack arguments\n\
-	stmdb	sp!, {r0-r3}\n\
-\n\
-	@ get pointer to linker struct\n\
-	ldr	r0, [lr, #-4]\n\
-\n\
-	@ prepare to call fixup()\n\
-	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
-	sub	r1, ip, lr\n\
-	sub	r1, r1, #4\n\
-	add	r1, r1, r1\n\
-\n\
-	@ call profiling fixup routine\n\
-	bl	profile_fixup\n\
-\n\
-	@ save the return\n\
-	mov	ip, r0\n\
-\n\
-	@ get arguments and return address back\n\
-	ldmia	sp!, {r0-r3,lr}\n\
-\n\
-	@ jump to the newly found address\n\
-	" BX(ip) "\n\
-\n\
-	.size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
-	.previous\n\
-");
-#else // PROF
-# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
-	.text\n\
-	.globl _dl_runtime_resolve\n\
-	.globl _dl_runtime_profile\n\
-	.type _dl_runtime_resolve, #function\n\
-	.type _dl_runtime_profile, #function\n\
-	.align 2\n\
-_dl_runtime_resolve:\n\
-_dl_runtime_profile:\n\
-	@ we get called with\n\
-	@ 	stack[0] contains the return address from this call\n\
-	@	ip contains &GOT[n+3] (pointer to function)\n\
-	@	lr points to &GOT[2]\n\
-\n\
-	@ stack arguments\n\
-	stmdb	sp!, {r0-r3}\n\
-\n\
-	@ get pointer to linker struct\n\
-	ldr	r0, [lr, #-4]\n\
-\n\
-	@ prepare to call fixup()\n\
-	@ change &GOT[n+3] into 8*n        NOTE: reloc are 8 bytes each\n\
-	sub	r1, ip, lr\n\
-	sub	r1, r1, #4\n\
-	add	r1, r1, r1\n\
-\n\
-	@ call profiling fixup routine\n\
-	bl	fixup\n\
-\n\
-	@ save the return\n\
-	mov	ip, r0\n\
-\n\
-	@ get arguments and return address back\n\
-	ldmia	sp!, {r0-r3,lr}\n\
-\n\
-	@ jump to the newly found address\n\
-	" BX(ip) "\n\
-\n\
-	.size _dl_runtime_profile, .-_dl_runtime_profile\n\
-	.previous\n\
-");
-#endif //PROF
-
 /* Mask identifying addresses reserved for the user program,
    where the dynamic linker should not map anything.  */
 #define ELF_MACHINE_USER_ADDRESS_MASK	0xf8000000UL
@@ -348,6 +235,10 @@
   return value;
 }
 
+/* Names of the architecture-specific auditing callback functions.  */
+#define ARCH_LA_PLTENTER arm_gnu_pltenter
+#define ARCH_LA_PLTEXIT arm_gnu_pltexit
+
 #endif /* !dl_machine_h */
 
 
@@ -355,7 +246,7 @@
    Prelinked libraries may use Elf32_Rela though.  */
 #define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
 
-#ifdef RESOLVE
+#ifdef RESOLVE_MAP
 
 /* Deal with an out-of-range PC24 reloc.  */
 static Elf32_Addr
@@ -425,7 +316,8 @@
 #endif
     {
       const Elf32_Sym *const refsym = sym;
-      Elf32_Addr value = RESOLVE (&sym, version, r_type);
+      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
       if (sym)
 	value += sym->st_value;
 
@@ -535,7 +427,8 @@
 # ifndef RESOLVE_CONFLICT_FIND_MAP
       const Elf32_Sym *const refsym = sym;
 # endif
-      Elf32_Addr value = RESOLVE (&sym, version, r_type);
+      struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+      Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
       if (sym)
 	value += sym->st_value;
 
@@ -637,4 +530,4 @@
     _dl_reloc_bad_type (map, r_type, 1);
 }
 
-#endif /* RESOLVE */
+#endif /* RESOLVE_MAP */