From owner-freebsd-questions@freebsd.org Wed Jan 4 16:14:33 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05FC8C9EB94 for ; Wed, 4 Jan 2017 16:14:33 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.117.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9F5C31DF7 for ; Wed, 4 Jan 2017 16:14:32 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from host-4-75.office.adestra.com (unknown [85.199.232.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id 06F7D9F5C for ; Wed, 4 Jan 2017 16:14:21 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/06F7D9F5C; dkim=none; dkim-atps=neutral Subject: Re: Using non-standard libc To: freebsd-questions@freebsd.org References: From: Matthew Seaman Message-ID: Date: Wed, 4 Jan 2017 16:14:14 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pCDWmNeaTX3sf0SjaE1W490r7vmme3eRM" X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00,RCVD_IN_RP_RNBL, RDNS_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on smtp.infracaninophile.co.uk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2017 16:14:33 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pCDWmNeaTX3sf0SjaE1W490r7vmme3eRM Content-Type: multipart/mixed; boundary="bkwKa83sgbKnNokldxkX5uvv8FLtwAmID"; protected-headers="v1" From: Matthew Seaman To: freebsd-questions@freebsd.org Message-ID: Subject: Re: Using non-standard libc References: In-Reply-To: --bkwKa83sgbKnNokldxkX5uvv8FLtwAmID Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2017/01/04 15:51, Derrick McKee wrote: > Hi, >=20 > I am conducting research into memory safety, and I have developed a cus= tom > LLVM pass. I have successfully built libc using my pass. However, whe= n I > try to compile a helloworld program using my built libc, I get a whole > bunch of undefined reference errors: >=20 > /path/to/custom/clang -static -nostdlib -L/usr/src/lib/libc -lc > -I/usr/src/include hello.c >=20 > /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to > 0000000000400160 > /usr/src/lib/libc/libc.a(getenv.o): In function `__clean_env': > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x168): undefined reference to= > `environ' > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x171): undefined reference to= > `environ' > /usr/src/lib/libc/libc.a(getenv.o): In function `getenv': > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x1f6): undefined reference to= > `environ' > /usr/src/lib/libc/libc.a(getenv.o): In function `__merge_environ': > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x42d): undefined reference to= > `environ' > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x459): undefined reference to= > `environ' > /usr/src/lib/libc/libc.a(getenv.o):/usr/src/lib/libc/stdlib/getenv.c:(.= text+0x524): > more undefined references to `environ' follow > /usr/src/lib/libc/libc.a(getprogname.o): In function `getprogname': > /usr/src/lib/libc/gen/getprogname.c:(.text+0x7): undefined reference to= > `__progname' > /usr/src/lib/libc/libc.a(auxv.o): In function `init_aux_vector_once': > /usr/src/lib/libc/gen/auxv.c:(.text+0x27): undefined reference to `envi= ron' > /usr/src/lib/libc/libc.a(exec.o): In function `execl': > /usr/src/lib/libc/gen/exec.c:(.text+0x154): undefined reference to `env= iron' > /usr/src/lib/libc/libc.a(exec.o): In function `execlp': > /usr/src/lib/libc/gen/exec.c:(.text+0x484): undefined reference to `env= iron' > /usr/src/lib/libc/libc.a(exec.o): In function `execvp': > /usr/src/lib/libc/gen/exec.c:(.text+0x4e3): undefined reference to `env= iron' > /usr/src/lib/libc/libc.a(exec.o): In function `execv': > /usr/src/lib/libc/gen/exec.c:(.text+0x537): undefined reference to `env= iron' > /usr/src/lib/libc/libc.a(exec.o):/usr/src/lib/libc/gen/exec.c:(.text+0x= 5b7): > more undefined references to `environ' follow > clang-4.0: error: linker command failed with exit code 1 (use -v to see= > invocation) >=20 > Any idea what I am missing? Thanks. >=20 This is definitely a question for freebsd-hackers@freebsd.org -- that's where the people into toolchain development tend to hang out. I couldn't tell you much about what the problem here might be, other than hazarding a guess that you're missing linking against the C runtime which is called something like /usr/lib/crt.o (but there's about ten similar object files to choose from. No idea which (if any) is correct.)= Cheers, Matthew --bkwKa83sgbKnNokldxkX5uvv8FLtwAmID-- --pCDWmNeaTX3sf0SjaE1W490r7vmme3eRM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQJ8BAEBCgBmBQJYbR9dXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxOUYxNTRFQ0JGMTEyRTUwNTQ0RTNGMzAw MDUxM0YxMEUwQTlFNEU3AAoJEABRPxDgqeTnK/UP/A+rVM9XIFjg7fPMg0ohAstQ MJRUwqMRleo5UteyHtlDs/g+2ZLo1SsThd3UvV5tB+5nJaTLo1ZdO0/YkXxZ3AIi nwgEEKVkd2Cxe7dU5y6Wjb6s52p7a8UE0rRo9k8DIheUdKmCJgnQH9u9UxoyQRxA voGIbK5VeAFOHwGW1pa79By/WIX1elBCLWFjaaSdIWoQ9rbxX6VT7EsJopRv7GL2 YOXR9PtQ3pGlobKEeP3JWLBZh32RMdSzzXPzR/x/Kwq6N6whIZqw5a8Ie9n/wb/Q RuVn1P69GmYQo2d/0X1zX0WSxikc39xoZ+f8TGdc9CxEODN58A6pu2ORQ94wn8S5 31Mz6VtMjh/VB9nGi3GAK7aNc6hVjIWiq1XyCGkagOFehYuGOhBRrcLmLBg8rQh5 qCYH8CyLuMbG6JwivnUAuOpQpHwDH5gq/P03/AaL490BLGHdubXrFmPgvhn5aG/C ls3P9aVGxbIA8n+5iGURrPH1gRTlYNpPO08M2MzN7z85pEkCTNNDshzFYQotE5Rq 0gQCNEsgfFySSLIL9QTS0r/+RQxNS//y+8an8TMvLQxHWAIba6xlHSBVf5AyHn2O Evr49VjLCMQ+yHgPRQMM0O1Eq24QeGYISPOtgix+le3VlfPtOT2jr+Z7VdRjd/ic tXOSWuenM1UmZMER6Dtd =pw9A -----END PGP SIGNATURE----- --pCDWmNeaTX3sf0SjaE1W490r7vmme3eRM--