Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Jan 2017 15:51:55 +0000
From:      Derrick McKee <derrick.mckee@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Using non-standard libc
Message-ID:  <CAJoBWHxmgo00FjRftxE5RpCe3%2B1jgr%2BiU_m2rufBAz9yWab7nw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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.
-- 
Derrick McKee
Ph.D. Student at Purdue University



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJoBWHxmgo00FjRftxE5RpCe3%2B1jgr%2BiU_m2rufBAz9yWab7nw>