Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jan 2017 16:14:14 +0000
From:      Matthew Seaman <matthew@FreeBSD.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: Using non-standard libc
Message-ID:  <c97106b3-4f1b-f5ce-1b5b-237d69c61922@FreeBSD.org>
In-Reply-To: <CAJoBWHxmgo00FjRftxE5RpCe3%2B1jgr%2BiU_m2rufBAz9yWab7nw@mail.gmail.com>
References:  <CAJoBWHxmgo00FjRftxE5RpCe3%2B1jgr%2BiU_m2rufBAz9yWab7nw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--pCDWmNeaTX3sf0SjaE1W490r7vmme3eRM
Content-Type: multipart/mixed; boundary="bkwKa83sgbKnNokldxkX5uvv8FLtwAmID";
 protected-headers="v1"
From: Matthew Seaman <matthew@FreeBSD.org>
To: freebsd-questions@freebsd.org
Message-ID: <c97106b3-4f1b-f5ce-1b5b-237d69c61922@FreeBSD.org>
Subject: Re: Using non-standard libc
References: <CAJoBWHxmgo00FjRftxE5RpCe3+1jgr+iU_m2rufBAz9yWab7nw@mail.gmail.com>
In-Reply-To: <CAJoBWHxmgo00FjRftxE5RpCe3+1jgr+iU_m2rufBAz9yWab7nw@mail.gmail.com>

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c97106b3-4f1b-f5ce-1b5b-237d69c61922>