1 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
2 Return-Path: <libc-alpha-return-16890-listarch-libc-alpha=sources dot redhat dot com at sources dot redhat dot com>
3 Delivered-To: listarch-libc-alpha at sources dot redhat dot com
4 Received: (qmail 26073 invoked by alias); 19 Jan 2005 18:02:41 -0000
5 Mailing-List: contact libc-alpha-help at sources dot redhat dot com; run by ezmlm
7 List-Subscribe: <mailto:libc-alpha-subscribe at sources dot redhat dot com>
8 List-Archive: <http://sources.redhat.com/ml/libc-alpha/>
9 List-Post: <mailto:libc-alpha at sources dot redhat dot com>
10 List-Help: <mailto:libc-alpha-help at sources dot redhat dot com>, <http://sources dot redhat dot com/ml/#faqs>
11 Sender: libc-alpha-owner at sources dot redhat dot com
12 Delivered-To: mailing list libc-alpha at sources dot redhat dot com
13 Received: (qmail 25420 invoked from network); 19 Jan 2005 18:01:47 -0000
14 Received: from unknown (HELO mail.codesourcery.com) (65.74.133.9)
15 by sourceware dot org with SMTP; 19 Jan 2005 18:01:47 -0000
16 Received: (qmail 7456 invoked from network); 19 Jan 2005 18:01:44 -0000
17 Received: from localhost (HELO ?192.168.0.100?) (mitchell@127.0.0.1)
18 by mail dot codesourcery dot com with SMTP; 19 Jan 2005 18:01:44 -0000
19 Message-ID: <41EEA082.1020000@codesourcery.com>
20 Date: Wed, 19 Jan 2005 10:01:38 -0800
21 From: Mark Mitchell <mark at codesourcery dot com>
22 Organization: CodeSourcery, LLC
23 User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103)
25 To: Daniel Jacobowitz <drow at false dot org>
26 CC: libc-alpha at sources dot redhat dot com
27 Subject: Re: PATCH: ARM dl-trampoline.S
28 References: <200501191631.j0JGVVRA002591@sirius.codesourcery.com> <20050119170217.GA3137@nevyn.them.org>
29 In-Reply-To: <20050119170217 dot GA3137 at nevyn dot them dot org>
30 Content-Type: multipart/mixed;
31 boundary="------------050601050507020101060100"
33 This is a multi-part message in MIME format.
34 --------------050601050507020101060100
35 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
36 Content-Transfer-Encoding: 7bit
38 Daniel Jacobowitz wrote:
39 > On Wed, Jan 19, 2005 at 08:31:31AM -0800, Mark Mitchell wrote:
41 >>This patch updates the ARM port for the recent dl-trampoline.S and
42 >>link.h changes. OK to apply?
45 > Did you test this? I'm pretty sure that RESOLVE_MAP returns a link
46 > map, unlike RESOLVE.
48 No, I didn't test -- except by building glibc. (There are other
49 problems at the moment, AFAICT, with actually running the library on ARM.)
51 However, you're definitely correct -- good catch! -- and, in fact, in
52 looking at my logs I see compiler warnings about the mismatched type
53 assignment. Here is a more plausible version. How about this one?
63 --------------050601050507020101060100
64 Content-Type: text/plain;
66 Content-Transfer-Encoding: 7bit
67 Content-Disposition: inline;
68 filename="glibc.patch"
70 2005-01-19 Mark Mitchell <mark@codesourcery.com>
72 * elf/tst-auditmod1.c: Add ARM support.
73 * sysdeps/arm/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
75 (RESOLVE): Do not use it; use ...
76 (RESOLVE_MAP): ... instead.
77 (ARCH_LA_PLTENTER): Define.
78 (ARCH_LA_PLTEXIT): Likewise.
79 (elf_machine_rel): Use RESOLVE_MAP, not RESOLVE.
80 (elf_machine_rela): Likewise.
81 * sysdeps/arm/dl-trampoline.S: New file.
82 * sysdeps/arm/bits/link.h: Likewise.
83 * sysdeps/generic/ldsodefs.h (struct La_arm_regs): Declare.
84 (struct audit_ifaces): Add ARM functions.
86 Index: elf/tst-auditmod1.c
87 ===================================================================
88 RCS file: /cvs/glibc/libc/elf/tst-auditmod1.c,v
89 retrieving revision 1.7
90 diff -c -5 -p -r1.7 tst-auditmod1.c
91 *** elf/tst-auditmod1.c 16 Jan 2005 06:24:59 -0000 1.7
92 --- elf/tst-auditmod1.c 19 Jan 2005 17:54:32 -0000
93 *************** la_symbind64 (Elf64_Sym *sym, unsigned i
95 symname, (long int) sym->st_value, ndx, *flags);
101 # define pltenter la_i86_gnu_pltenter
102 # define pltexit la_i86_gnu_pltexit
103 # define La_regs La_i86_regs
104 # define La_retval La_i86_retval
105 # define int_retval lrv_eax
107 symname, (long int) sym->st_value, ndx, *flags);
109 return sym->st_value;
113 ! # define pltenter la_arm_gnu_plteneter
114 ! # define pltext la_arm_gnu_pltexit
115 ! # define La_regs La_arm_regs
116 ! # define La_retval La_arm_retval
117 ! # define int_retval lvr_r0
118 ! #elif defined __i386__
119 # define pltenter la_i86_gnu_pltenter
120 # define pltexit la_i86_gnu_pltexit
121 # define La_regs La_i86_regs
122 # define La_retval La_i86_retval
123 # define int_retval lrv_eax
124 Index: sysdeps/arm/dl-trampoline.S
125 ===================================================================
126 RCS file: sysdeps/arm/dl-trampoline.S
127 diff -N sysdeps/arm/dl-trampoline.S
128 *** /dev/null 1 Jan 1970 00:00:00 -0000
129 --- sysdeps/arm/dl-trampoline.S 19 Jan 2005 17:54:32 -0000
133 + /* PLT trampolines. ARM version.
134 + Copyright (C) 2005 Free Software Foundation, Inc.
135 + This file is part of the GNU C Library.
137 + The GNU C Library is free software; you can redistribute it and/or
138 + modify it under the terms of the GNU Lesser General Public
139 + License as published by the Free Software Foundation; either
140 + version 2.1 of the License, or (at your option) any later version.
142 + The GNU C Library is distributed in the hope that it will be useful,
143 + but WITHOUT ANY WARRANTY; without even the implied warranty of
144 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
145 + Lesser General Public License for more details.
147 + You should have received a copy of the GNU Lesser General Public
148 + License along with the GNU C Library; if not, write to the Free
149 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
152 + #include <sysdep.h>
154 + #if defined(__USE_BX__)
157 + #define BX(x) mov pc, x
162 + .globl _dl_runtime_resolve
163 + .type _dl_runtime_resolve, #function
165 + _dl_runtime_resolve:
166 + @ we get called with
167 + @ stack[0] contains the return address from this call
168 + @ ip contains &GOT[n+3] (pointer to function)
169 + @ lr points to &GOT[2]
174 + @ get pointer to linker struct
177 + @ prepare to call _dl_fixup()
178 + @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
183 + @ call fixup routine
189 + @ get arguments and return address back
190 + ldmia sp!, {r0-r3,lr}
192 + @ jump to the newly found address
195 + .size _dl_runtime_resolve, .-_dl_runtime_resolve
197 + .globl _dl_runtime_profile
198 + .type _dl_runtime_profile, #function
200 + _dl_runtime_profile:
204 + @ get pointer to linker struct
207 + @ prepare to call _dl_profile_fixup()
208 + @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
213 + @ call profiling fixup routine
214 + bl _dl_profile_fixup
219 + @ get arguments and return address back
220 + ldmia sp!, {r0-r3,lr}
222 + @ jump to the newly found address
225 + .size _dl_runtime_resolve, .-_dl_runtime_resolve
229 + .globl _dl_runtime_resolve
230 + .globl _dl_runtime_profile
231 + .type _dl_runtime_resolve, #function
232 + .type _dl_runtime_profile, #function
234 + _dl_runtime_resolve:
235 + _dl_runtime_profile:
236 + @ we get called with
237 + @ stack[0] contains the return address from this call
238 + @ ip contains &GOT[n+3] (pointer to function)
239 + @ lr points to &GOT[2]
244 + @ get pointer to linker struct
247 + @ prepare to call _dl_fixup()
248 + @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
253 + @ call profiling fixup routine
259 + @ get arguments and return address back
260 + ldmia sp!, {r0-r3,lr}
262 + @ jump to the newly found address
265 + .size _dl_runtime_profile, .-_dl_runtime_profile
268 Index: sysdeps/arm/bits/link.h
269 ===================================================================
270 RCS file: /cvs/glibc/libc/sysdeps/arm/bits/link.h,v
271 retrieving revision 1.2
272 diff -c -5 -p -r1.2 link.h
273 *** sysdeps/arm/bits/link.h 6 Jan 2005 22:40:20 -0000 1.2
274 --- sysdeps/arm/bits/link.h 19 Jan 2005 17:54:32 -0000
278 + /* Copyright (C) 2005 Free Software Foundation, Inc.
279 + This file is part of the GNU C Library.
281 + The GNU C Library is free software; you can redistribute it and/or
282 + modify it under the terms of the GNU Lesser General Public
283 + License as published by the Free Software Foundation; either
284 + version 2.1 of the License, or (at your option) any later version.
286 + The GNU C Library is distributed in the hope that it will be useful,
287 + but WITHOUT ANY WARRANTY; without even the implied warranty of
288 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
289 + Lesser General Public License for more details.
291 + You should have received a copy of the GNU Lesser General Public
292 + License along with the GNU C Library; if not, write to the Free
293 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
297 + # error "Never include <bits/link.h> directly; use <link.h> instead."
301 + /* Registers for entry into PLT on ARM. */
302 + typedef struct La_arm_regs
310 + /* Return values for calls from PLT on ARM. */
311 + typedef struct La_arm_retval
320 + extern Elf32_Addr la_arm_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
321 + uintptr_t *__refcook,
322 + uintptr_t *__defcook,
323 + La_arm_regs *__regs,
324 + unsigned int *__flags,
325 + const char *__symname,
326 + long int *__framesizep);
327 + extern unsigned int la_arm_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
328 + uintptr_t *__refcook,
329 + uintptr_t *__defcook,
330 + const La_arm_regs *__inregs,
331 + La_arm_retval *__outregs,
332 + const char *symname);
335 Index: sysdeps/generic/ldsodefs.h
336 ===================================================================
337 RCS file: /cvs/glibc/libc/sysdeps/generic/ldsodefs.h,v
338 retrieving revision 1.112
339 diff -c -5 -p -r1.112 ldsodefs.h
340 *** sysdeps/generic/ldsodefs.h 16 Jan 2005 02:07:29 -0000 1.112
341 --- sysdeps/generic/ldsodefs.h 19 Jan 2005 17:54:32 -0000
342 *************** enum allowmask
349 /* Type for list of auditing interfaces. */
350 + struct La_arm_regs;
352 struct La_i86_retval;
353 struct La_x86_64_regs;
354 struct La_x86_64_retval;
355 struct La_ppc32_regs;
356 *************** struct audit_ifaces
359 uintptr_t (*symbind64) (Elf64_Sym *, unsigned int, uintptr_t *,
360 uintptr_t *, unsigned int *, const char *);
364 + Elf32_Addr (*arm_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *,
365 + uintptr_t *, struct La_arm_regs *,
366 + unsigned int *, const char *name,
367 + long int *framesizep);
368 Elf32_Addr (*i86_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *,
369 uintptr_t *, struct La_i86_regs *,
370 unsigned int *, const char *name,
371 long int *framesizep);
372 Elf64_Addr (*x86_64_gnu_pltenter) (Elf64_Sym *, unsigned int, uintptr_t *,
373 *************** struct audit_ifaces
376 unsigned int *, const char *name,
377 long int *framesizep);
381 + unsigned int (*arm_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *,
382 + uintptr_t *, const struct La_arm_regs *,
383 + struct La_i86_retval *, const char *);
384 unsigned int (*i86_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *,
385 uintptr_t *, const struct La_i86_regs *,
386 struct La_i86_retval *, const char *);
387 unsigned int (*x86_64_gnu_pltexit) (Elf64_Sym *, unsigned int, uintptr_t *,
390 --------------050601050507020101060100--
392 diff -u -r1.52 dl-machine.h
393 --- sysdeps/arm/dl-machine.h 15 Mar 2005 22:57:26 -0000 1.52
394 +++ sysdeps/arm/dl-machine.h 22 Apr 2005 03:38:15 -0000
395 @@ -129,119 +129,6 @@
396 #define BX(x) "mov\tpc, " #x
400 -# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
402 - .globl _dl_runtime_resolve\n\
403 - .type _dl_runtime_resolve, #function\n\
405 -_dl_runtime_resolve:\n\
406 - @ we get called with\n\
407 - @ stack[0] contains the return address from this call\n\
408 - @ ip contains &GOT[n+3] (pointer to function)\n\
409 - @ lr points to &GOT[2]\n\
411 - @ stack arguments\n\
412 - stmdb sp!,{r0-r3}\n\
414 - @ get pointer to linker struct\n\
415 - ldr r0, [lr, #-4]\n\
417 - @ prepare to call fixup()\n\
418 - @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\
423 - @ call fixup routine\n\
426 - @ save the return\n\
429 - @ get arguments and return address back\n\
430 - ldmia sp!, {r0-r3,lr}\n\
432 - @ jump to the newly found address\n\
435 - .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
437 - .globl _dl_runtime_profile\n\
438 - .type _dl_runtime_profile, #function\n\
440 -_dl_runtime_profile:\n\
441 - @ stack arguments\n\
442 - stmdb sp!, {r0-r3}\n\
444 - @ get pointer to linker struct\n\
445 - ldr r0, [lr, #-4]\n\
447 - @ prepare to call fixup()\n\
448 - @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\
453 - @ call profiling fixup routine\n\
454 - bl profile_fixup\n\
456 - @ save the return\n\
459 - @ get arguments and return address back\n\
460 - ldmia sp!, {r0-r3,lr}\n\
462 - @ jump to the newly found address\n\
465 - .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
469 -# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
471 - .globl _dl_runtime_resolve\n\
472 - .globl _dl_runtime_profile\n\
473 - .type _dl_runtime_resolve, #function\n\
474 - .type _dl_runtime_profile, #function\n\
476 -_dl_runtime_resolve:\n\
477 -_dl_runtime_profile:\n\
478 - @ we get called with\n\
479 - @ stack[0] contains the return address from this call\n\
480 - @ ip contains &GOT[n+3] (pointer to function)\n\
481 - @ lr points to &GOT[2]\n\
483 - @ stack arguments\n\
484 - stmdb sp!, {r0-r3}\n\
486 - @ get pointer to linker struct\n\
487 - ldr r0, [lr, #-4]\n\
489 - @ prepare to call fixup()\n\
490 - @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\
495 - @ call profiling fixup routine\n\
498 - @ save the return\n\
501 - @ get arguments and return address back\n\
502 - ldmia sp!, {r0-r3,lr}\n\
504 - @ jump to the newly found address\n\
507 - .size _dl_runtime_profile, .-_dl_runtime_profile\n\
512 /* Mask identifying addresses reserved for the user program,
513 where the dynamic linker should not map anything. */
514 #define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
519 +/* Names of the architecture-specific auditing callback functions. */
520 +#define ARCH_LA_PLTENTER arm_gnu_pltenter
521 +#define ARCH_LA_PLTEXIT arm_gnu_pltexit
523 #endif /* !dl_machine_h */
527 Prelinked libraries may use Elf32_Rela though. */
528 #define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
533 /* Deal with an out-of-range PC24 reloc. */
538 const Elf32_Sym *const refsym = sym;
539 - Elf32_Addr value = RESOLVE (&sym, version, r_type);
540 + struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
541 + Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
543 value += sym->st_value;
546 # ifndef RESOLVE_CONFLICT_FIND_MAP
547 const Elf32_Sym *const refsym = sym;
549 - Elf32_Addr value = RESOLVE (&sym, version, r_type);
550 + struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
551 + Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
553 value += sym->st_value;
556 _dl_reloc_bad_type (map, r_type, 1);
559 -#endif /* RESOLVE */
560 +#endif /* RESOLVE_MAP */