Subject: Re: Compilation issues during compilation of an application
To: Bharat Joshi <firstname.lastname@example.org>
From: Nick Hudson <email@example.com>
Date: 12/16/2005 14:05:49
On Friday 16 December 2005 09:24, Bharat Joshi wrote:
> Hi All,
> We have an internal NetBSD distribution which differs from
> standard NetBSD distribution because we have defined our own malloc
> library instead of usual malloc.
> I am compiling loader "ld.elf_so" which defines its own "malloc".
> The loader was compiling without any issues with below mentioned
> Command to compile "ld.elf_so" is as follows:
> Command for compiling:
> i386--netbsdelf-gcc -O3 -fomit-frame-pointer -Wall -Wstrict-prototypes
> -Wmissing-prototypes -Wpointer-arith -Wno-sign-compare -Wno-traditional
> -Wno-uninitialized -Werror -fpic -DELFSIZE=32 -DLIBDIR=\"/usr/lib\"
> <includes> -c <sourcefile>
> Command for linking:
> i386--netbsdelf-gcc -shared -symbolic -nostartfiles -Wl,-non_shared
> -Wl,-e -Wl,.rtld_start -o <output> <objectfiles> -L<libpath> -lc_pic
> -lmalloc -lc -lgcc
I guess you really want
i386--netbsdelf-gcc -shared -symbolic -nostartfiles -Wl,-non_shared \
-Wl,-e -Wl,.rtld_start -o <output> <objectfiles> -L<libpath> \
i.e. -lmalloc before -lc_pic so that the reference to malloc will be satisfied
> Note: our internal malloc library is also linked but gcc never throw
> any error for multiple definition of "malloc".
> I wanted to create a profiling load of this application so I add
> "-pg" flag in the compilation. Compilation threw a warning that "-pg"
> and "-fomit-frame-pointer" can not be enabled together. So I removed
> "-fomit-frame-pointer" flag. Now compilation threw following warning:
> (malloc.o)(.text+0x5d0): In function `malloc':
> : multiple definition of `malloc'
> malloc.o(.text+0x0): first defined here
> Warning: size of symbol `malloc' changed from 280 in malloc.o to 107 in
You'll have to link against archives for libc/libmallc of objects created with