Subject: Compilation issues during compilation of an application
To: None <>
From: Bharat Joshi <>
List: tech-toolchain
Date: 12/16/2005 14:54:25
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=3D32 -DLIBDIR=3D\"/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

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

   I am trying to figure out the difference "-pg" flag would have made
here so that compilation failed with the above error. I tried searching
through webpages but could not find the reason for this.

   If any more information is required, please let me know.

   Any help would be greatly appreciated.

Thanks & Regards,
Bharat Joshi

"gcc" version used for compilation is:
Thread model: posix
gcc version 3.3.3 (NetBSD nb3 20040520)

Linker "i386--netbsdelf/bin/ld" version used for linking is:
GNU ld version 2.14 20030612