Using non-standard libc

Matthew Seaman matthew at FreeBSD.org
Wed Jan 4 16:14:33 UTC 2017


On 2017/01/04 15:51, Derrick McKee wrote:
> Hi,
> 
> I am conducting research into memory safety, and I have developed a custom
> LLVM pass.  I have successfully built libc using my pass.  However, when I
> try to compile a helloworld program using my built libc, I get a whole
> bunch of undefined reference errors:
> 
> /path/to/custom/clang -static -nostdlib -L/usr/src/lib/libc -lc
> -I/usr/src/include hello.c
> 
> /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 `environ'
> /usr/src/lib/libc/libc.a(exec.o): In function `execl':
> /usr/src/lib/libc/gen/exec.c:(.text+0x154): undefined reference to `environ'
> /usr/src/lib/libc/libc.a(exec.o): In function `execlp':
> /usr/src/lib/libc/gen/exec.c:(.text+0x484): undefined reference to `environ'
> /usr/src/lib/libc/libc.a(exec.o): In function `execvp':
> /usr/src/lib/libc/gen/exec.c:(.text+0x4e3): undefined reference to `environ'
> /usr/src/lib/libc/libc.a(exec.o): In function `execv':
> /usr/src/lib/libc/gen/exec.c:(.text+0x537): undefined reference to `environ'
> /usr/src/lib/libc/libc.a(exec.o):/usr/src/lib/libc/gen/exec.c:(.text+0x5b7):
> more undefined references to `environ' follow
> clang-4.0: error: linker command failed with exit code 1 (use -v to see
> invocation)
> 
> Any idea what I am missing?  Thanks.
> 

This is definitely a question for freebsd-hackers at 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



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 972 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20170104/fa86c579/attachment.sig>


More information about the freebsd-questions mailing list