Wed Dec 23 03:14:47 2009 UTC ()
pull across from -current:
> Log Message:
> - adjust the logic for compat ldd: add an elf32_compat module and arrange
>   for mips64 to build this with MLIBDIR set to o32
> - make mips64 ldd call elf32_compat_ldd as well
> - make mips64 elf64 set MLIBDIR to 64
> - don't need ld.elf_so's Makefile.ld32 files anymore (they are going away
>   soon anyway)
>
> tested on amd64 and sparc64, and an earlier version tested on mips64.

> Log Message:
> make this actually build on mips64.


(mrg)
diff -r1.7.52.1.4.2 -r1.7.52.1.4.3 src/usr.bin/ldd/Makefile
diff -r1.1 -r1.1.58.1 src/usr.bin/ldd/Makefile.inc
diff -r1.2.12.2 -r1.2.12.2.4.1 src/usr.bin/ldd/ldd.c
diff -r1.1.2.3 -r1.1.2.3.4.1 src/usr.bin/ldd/ldd.h
diff -r0 -r1.1.2.2 src/usr.bin/ldd/elf32_compat/Makefile
diff -r1.4.2.2.4.2 -r1.4.2.2.4.3 src/usr.bin/ldd/elf64/Makefile

cvs diff -r1.7.52.1.4.2 -r1.7.52.1.4.3 src/usr.bin/ldd/Makefile (expand / switch to unified diff)

--- src/usr.bin/ldd/Makefile 2009/09/05 18:53:57 1.7.52.1.4.2
+++ src/usr.bin/ldd/Makefile 2009/12/23 03:14:47 1.7.52.1.4.3
@@ -1,37 +1,39 @@ @@ -1,37 +1,39 @@
1# $NetBSD: Makefile,v 1.7.52.1.4.2 2009/09/05 18:53:57 matt Exp $ 1# $NetBSD: Makefile,v 1.7.52.1.4.3 2009/12/23 03:14:47 mrg Exp $
2 2
3.include <bsd.own.mk> # for MKDYNAMICROOT definition 3.include <bsd.own.mk> # for MKDYNAMICROOT definition
4 4
5PROG= ldd 5PROG= ldd
6SRCS= ldd.c 6SRCS= ldd.c
7MAN= ldd.1 7MAN= ldd.1
8 8
9SUBDIR= aout elf32 elf64 9SUBDIR= aout elf32 elf64 elf32_compat
 10
10LIB_AOUTDIR!= cd ${.CURDIR}/aout && ${PRINTOBJDIR} 11LIB_AOUTDIR!= cd ${.CURDIR}/aout && ${PRINTOBJDIR}
11EXTRA_LIBS+= ${LIB_AOUTDIR}/libldd_aout.a 12EXTRA_LIBS+= ${LIB_AOUTDIR}/libldd_aout.a
12 13
13.if (${MACHINE_ARCH} != "alpha") 14.if (${MACHINE_ARCH} != "alpha")
14LIB_ELF32DIR!= cd ${.CURDIR}/elf32 && ${PRINTOBJDIR} 15LIB_ELF32DIR!= cd ${.CURDIR}/elf32 && ${PRINTOBJDIR}
15EXTRA_LIBS+= ${LIB_ELF32DIR}/libldd_elf32.a 16EXTRA_LIBS+= ${LIB_ELF32DIR}/libldd_elf32.a
16.endif 17.endif
17 18
18.if (${MACHINE_ARCH} == "mips64eb") || (${MACHINE_ARCH} == "mips64el") 19.if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
19ABI64:= ${CPUFLAGS:M-mabi=64:M-mabi=o64} 20LIB_ELF32COMPATDIR!= cd ${.CURDIR}/elf32_compat && ${PRINTOBJDIR}
 21EXTRA_LIBS+= ${LIB_ELF32COMPATDIR}/libldd_elf32_compat.a
20.endif 22.endif
21 23
22.if (${MACHINE_ARCH} == "alpha") || (${MACHINE_ARCH} == "sparc64") || \ 24.if (${MACHINE_ARCH} == "alpha") || (${MACHINE_ARCH} == "sparc64") || \
23 (${MACHINE_ARCH} == "x86_64") || (${MACHINE_ARCH} == "powerpc64") || \ 25 (${MACHINE_ARCH} == "x86_64") || (${MACHINE_ARCH} == "powerpc64") || \
24 ((${MACHINE_ARCH:Mmips64*} != "") && !empty(ABI64)) 26 (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
25LIB_ELF64DIR!= cd ${.CURDIR}/elf64 && ${PRINTOBJDIR} 27LIB_ELF64DIR!= cd ${.CURDIR}/elf64 && ${PRINTOBJDIR}
26EXTRA_LIBS+= ${LIB_ELF64DIR}/libldd_elf64.a 28EXTRA_LIBS+= ${LIB_ELF64DIR}/libldd_elf64.a
27CPPFLAGS.ldd.c= -DELFSIZE=64 29CPPFLAGS.ldd.c= -DELFSIZE=64
28.else 30.else
29CPPFLAGS.ldd.c= -DELFSIZE=32 31CPPFLAGS.ldd.c= -DELFSIZE=32
30.endif 32.endif
31 33
32LDADD+= ${EXTRA_LIBS} 34LDADD+= ${EXTRA_LIBS}
33DPADD+= ${EXTRA_LIBS} 35DPADD+= ${EXTRA_LIBS}
34 36
35.include "Makefile.common" 37.include "Makefile.common"
36 38
37.if (${MKDYNAMICROOT} == "no") 39.if (${MKDYNAMICROOT} == "no")

cvs diff -r1.1 -r1.1.58.1 src/usr.bin/ldd/Makefile.inc (expand / switch to unified diff)

--- src/usr.bin/ldd/Makefile.inc 1998/12/15 22:07:11 1.1
+++ src/usr.bin/ldd/Makefile.inc 2009/12/23 03:14:47 1.1.58.1
@@ -1,5 +1,24 @@ @@ -1,5 +1,24 @@
1# $NetBSD: Makefile.inc,v 1.1 1998/12/15 22:07:11 pk Exp $ 1# $NetBSD: Makefile.inc,v 1.1.58.1 2009/12/23 03:14:47 mrg Exp $
 2
 3.if ${MACHINE_ARCH} == "sparc64"
 4MLIBDIR= sparc
 5.endif
 6
 7.if ${MACHINE_ARCH} == "x86_64"
 8MLIBDIR= i386
 9.endif
 10
 11.if ${MACHINE_ARCH} == "powerpc64"
 12MLIBDIR= powerpc
 13.endif
 14
 15# For now make "elf32" look for native (n32)
 16.if (${MACHINE_ARCH} == "mips64eb") || (${MACHINE_ARCH} == "mips64el")
 17MLIBDIR= 64
 18COMPAT_MLIBDIR= o32
 19CPPFLAGS+= -DLDD_ELF64
 20.endif
2 21
3.if exists(${.CURDIR}/../../Makefile.inc) 22.if exists(${.CURDIR}/../../Makefile.inc)
4.include "${.CURDIR}/../../Makefile.inc" 23.include "${.CURDIR}/../../Makefile.inc"
5.endif 24.endif

cvs diff -r1.2.12.2 -r1.2.12.2.4.1 src/usr.bin/ldd/ldd.c (expand / switch to unified diff)

--- src/usr.bin/ldd/ldd.c 2009/02/25 03:09:31 1.2.12.2
+++ src/usr.bin/ldd/ldd.c 2009/12/23 03:14:47 1.2.12.2.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ldd.c,v 1.2.12.2 2009/02/25 03:09:31 snj Exp $ */ 1/* $NetBSD: ldd.c,v 1.2.12.2.4.1 2009/12/23 03:14:47 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Kranenburg. 8 * by Paul Kranenburg.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 52 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
53 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 53 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
54 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 54 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
55 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 55 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64#ifndef lint 64#ifndef lint
65__RCSID("$NetBSD: ldd.c,v 1.2.12.2 2009/02/25 03:09:31 snj Exp $"); 65__RCSID("$NetBSD: ldd.c,v 1.2.12.2.4.1 2009/12/23 03:14:47 mrg Exp $");
66#endif /* not lint */ 66#endif /* not lint */
67 67
68#include <sys/types.h> 68#include <sys/types.h>
69#include <sys/mman.h> 69#include <sys/mman.h>
70#include <sys/wait.h> 70#include <sys/wait.h>
71 71
72#include <a.out.h> 72#include <a.out.h>
73#include <dirent.h> 73#include <dirent.h>
74#include <err.h> 74#include <err.h>
75#include <errno.h> 75#include <errno.h>
76#include <fcntl.h> 76#include <fcntl.h>
77#include <stdarg.h> 77#include <stdarg.h>
78#include <stdio.h> 78#include <stdio.h>
@@ -146,26 +146,29 @@ main(int argc, char **argv) @@ -146,26 +146,29 @@ main(int argc, char **argv)
146 146
147 for (; argc != 0; argc--, argv++) { 147 for (; argc != 0; argc--, argv++) {
148 int fd; 148 int fd;
149 149
150 fd = open(*argv, O_RDONLY); 150 fd = open(*argv, O_RDONLY);
151 if (fd == -1) { 151 if (fd == -1) {
152 warn("%s", *argv); 152 warn("%s", *argv);
153 continue; 153 continue;
154 } 154 }
155 if (elf_ldd(fd, *argv, fmt1, fmt2) == -1 && 155 if (elf_ldd(fd, *argv, fmt1, fmt2) == -1 &&
156 /* Alpha never had 32 bit support. */ 156 /* Alpha never had 32 bit support. */
157#if defined(_LP64) && !defined(__alpha__) 157#if defined(_LP64) && !defined(__alpha__)
158 elf32_ldd(fd, *argv, fmt1, fmt2) == -1 && 158 elf32_ldd(fd, *argv, fmt1, fmt2) == -1 &&
 159#ifdef __mips__
 160 && elf32_ldd_compat(fd, *argv, fmt1, fmt2) == -1
 161#endif
159#endif 162#endif
160 aout_ldd(fd, *argv, fmt1, fmt2) == -1) 163 aout_ldd(fd, *argv, fmt1, fmt2) == -1)
161 warnx("%s", error_message); 164 warnx("%s", error_message);
162 close(fd); 165 close(fd);
163 } 166 }
164 167
165 return 0; 168 return 0;
166} 169}
167 170
168/* 171/*
169 * Error reporting function. Use it like printf. If formats the message 172 * Error reporting function. Use it like printf. If formats the message
170 * into a buffer, and sets things up so that the next call to dlerror() 173 * into a buffer, and sets things up so that the next call to dlerror()
171 * will return the message. 174 * will return the message.

cvs diff -r1.1.2.3 -r1.1.2.3.4.1 src/usr.bin/ldd/ldd.h (expand / switch to unified diff)

--- src/usr.bin/ldd/ldd.h 2009/02/25 03:09:31 1.1.2.3
+++ src/usr.bin/ldd/ldd.h 2009/12/23 03:14:47 1.1.2.3.4.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ldd.h,v 1.1.2.3 2009/02/25 03:09:31 snj Exp $ */ 1/* $NetBSD: ldd.h,v 1.1.2.3.4.1 2009/12/23 03:14:47 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Matthew R. Green 4 * Copyright (c) 2008 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,24 +22,30 @@ @@ -22,24 +22,30 @@
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31int aout_ldd(int, char *, char *, char *); 31int aout_ldd(int, char *, char *, char *);
32int elf32_ldd(int, char *, char *, char *); 32int elf32_ldd(int, char *, char *, char *);
33 33
34#ifdef _LP64 34#ifdef _LP64
 35#define LDD_ELF64
 36#endif
 37
 38#ifdef LDD_ELF64
35int elf64_ldd(int, char *, char *, char *); 39int elf64_ldd(int, char *, char *, char *);
36#define elf_ldd elf64_ldd 40#define elf_ldd elf64_ldd
 41#elif defined(ELF32_COMPAT)
 42#define elf_ldd elf32_compat_ldd
37#else 43#else
38#define elf_ldd elf32_ldd 44#define elf_ldd elf32_ldd
39#endif 45#endif
40 46
41void fmtprint(const char *, Obj_Entry *, const char *, const char *); 47void fmtprint(const char *, Obj_Entry *, const char *, const char *);
42void print_needed(Obj_Entry *, const char *, const char *); 48void print_needed(Obj_Entry *, const char *, const char *);
43 49
44extern char *main_local; 50extern char *main_local;
45extern char *main_progname; 51extern char *main_progname;

File Added: src/usr.bin/ldd/elf32_compat/Makefile
#	$NetBSD: Makefile,v 1.1.2.2 2009/12/23 03:14:47 mrg Exp $

.include <bsd.own.mk>
.include <bsd.init.mk>

CPPFLAGS+=	-DELFSIZE=32 -DELF32_COMPAT
LIB=	ldd_elf32_compat

# XXX Force one member
SRCS=	dummy.c

LIBISPRIVATE=	yes
.PATH: ${.CURDIR}/..

.ifdef COMPAT_MLIBDIR
MLIBDIR=	${COMPAT_MLIBDIR}
CPPFLAGS+=	-DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
.endif

.ifdef MLIBDIR
.include "../Makefile.elf"
.endif

.include <bsd.lib.mk>

cvs diff -r1.4.2.2.4.2 -r1.4.2.2.4.3 src/usr.bin/ldd/elf64/Makefile (expand / switch to unified diff)

--- src/usr.bin/ldd/elf64/Makefile 2009/09/05 18:53:58 1.4.2.2.4.2
+++ src/usr.bin/ldd/elf64/Makefile 2009/12/23 03:14:47 1.4.2.2.4.3
@@ -1,45 +1,49 @@ @@ -1,45 +1,49 @@
1# $NetBSD: Makefile,v 1.4.2.2.4.2 2009/09/05 18:53:58 matt Exp $ 1# $NetBSD: Makefile,v 1.4.2.2.4.3 2009/12/23 03:14:47 mrg Exp $
2 2
3CPPFLAGS+= -DELFSIZE=64 3CPPFLAGS+= -DELFSIZE=64
4LIB= ldd_elf64 4LIB= ldd_elf64
5 5
6# XXX Force one member 6# XXX Force one member
7SRCS= dummy.c 7SRCS= dummy.c
8 8
9LIBISPRIVATE= yes 9LIBISPRIVATE= yes
10.PATH: ${.CURDIR}/.. 10.PATH: ${.CURDIR}/..
11 11
12.if ${MACHINE_ARCH:Mmips64*} != "" 12.if ${MACHINE_ARCH:Mmips64*} != ""
13ABI64:= ${CPUFLAGS:M-mabi=64:M-mabi=o64} 13ABI64:= ${CPUFLAGS:M-mabi=64:M-mabi=o64}
14.endif 14.endif
15 15
16.if (${MACHINE_ARCH} == "alpha") || (${MACHINE_ARCH} == "sparc64") || \ 16.if (${MACHINE_ARCH} == "alpha") || (${MACHINE_ARCH} == "sparc64") || \
17 (${MACHINE_ARCH} == "x86_64") || (${MACHINE_ARCH} == "powerpc64") || \ 17 (${MACHINE_ARCH} == "x86_64") || (${MACHINE_ARCH} == "powerpc64") || \
18 (${MACHINE_ARCH:Mmips64*} != "" && !empty(ABI64)) 18 (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
19 19
20# XXX we need to make sure that we don't accidentally get the elf32 20# XXX we need to make sure that we don't accidentally get the elf32
21# XXX versions of these. 21# XXX versions of these.
22 22
23RTLD_FUNCS = \ 23RTLD_FUNCS = \
24 _rtld_expand_path \ 24 _rtld_expand_path \
25 _rtld_digest_dynamic \ 25 _rtld_digest_dynamic \
26 _rtld_digest_phdr \ 26 _rtld_digest_phdr \
27 _rtld_load_needed_objects \ 27 _rtld_load_needed_objects \
28 _rtld_load_object \ 28 _rtld_load_object \
29 _rtld_map_object \ 29 _rtld_map_object \
30 _rtld_obj_free \ 30 _rtld_obj_free \
31 _rtld_obj_new \ 31 _rtld_obj_new \
32 _rtld_add_paths \ 32 _rtld_add_paths \
33 _rtld_process_hints \ 33 _rtld_process_hints \
34 _rtld_sysctl \ 34 _rtld_sysctl \
35 _rtld_load_library 35 _rtld_load_library
36 36
37.for _d in ${RTLD_FUNCS} 37.for _d in ${RTLD_FUNCS}
38CPPFLAGS+= -D${_d}=_elf64_${_d} 38CPPFLAGS+= -D${_d}=_elf64_${_d}
39.endfor 39.endfor
40 40
 41.if (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb")
 42CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
 43.endif
 44
41.include "../Makefile.elf" 45.include "../Makefile.elf"
42 46
43.endif 47.endif
44 48
45.include <bsd.lib.mk> 49.include <bsd.lib.mk>