This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Add new source files to the makefile system
- From: Wen Yaobin <robin dot wyb at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Thu, 15 Nov 2018 20:20:22 -0500
- Subject: Add new source files to the makefile system
Hi folks,
Recently I've got interested in learning the heap management of C (the
malloc module). I want to break the malloc source files, e.g. malloc.c,
arena.c, into smaller files so it's easier to read and study for me. I'm
using the glibc 2.23 and have successfully built it locally (in a separate
"build" folder) on Ubuntu 14.04 following the instructions on wiki.
As my initial attempt, I put the "__malloc_assert" into the files
"massert.h" and "massert.c" but then realized I have no idea how to add
them to the makefiles so they can get compiled and linked.
Since I moved "__malloc_assert" out of "malloc.c", I got the link errors
when running "make" again, which was expected:
```
/home/mvs/git/glibc/build/libc_pic.os: In function `detach_arena':
/home/mvs/git/glibc/malloc/arena.c:629: undefined reference to
`__malloc_assert'
/home/mvs/git/glibc/build/libc_pic.os: In function `mremap_chunk':
/home/mvs/git/glibc/malloc/malloc.c:2832: undefined reference to
`__malloc_assert'
/home/mvs/git/glibc/malloc/malloc.c:2813: undefined reference to
`__malloc_assert'
/home/mvs/git/glibc/malloc/malloc.c:2812: undefined reference to
`__malloc_assert'
/home/mvs/git/glibc/malloc/malloc.c:2830: undefined reference to
`__malloc_assert'
/home/mvs/git/glibc/build/libc_pic.os:/home/mvs/git/glibc/malloc/malloc.c:2776:
more undefined references to `__malloc_assert' follow
```
I thought I should look at how the "malloc/malloc.c" is used in the
makefiles, but I couldn't find where it is used. I'm mainly looking at the
following files:
- glibc/Makeconfig
- glibc/Makefile
- glibc/Rules
- glibc/malloc/Makefile
Alternatively, I've searched the "makefile" on "libc-help" mailing list and
looked at all the results but didn't find one that matches what I want. Two
of the threads, "glibc + add new function" and "Adding a function to
glibc?", were talking about adding a new function to the library, which is
not my case (I'm not adding new function but merely restructuring the code).
I'm kind of new to the makefile system and still reading the GNU makefile
manual, but thought shooting an email here may get me out of the struggle
more quickly.
Thanks!
Yaobin