Subject: Re: dynamic linker/loader problem
To: Rafal Boni <>
From: Manuel Bouyer <>
List: tech-toolchain
Date: 03/27/2003 21:31:21
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Mar 27, 2003 at 12:52:02PM -0500, Rafal Boni wrote:
> As Christos suggested, writing a simple program that uses termcap and
> also implements it's own malloc/free (mmm, reimplementing malloc/free
> with realloc... Almost worthy of libmem v2 8-) triggers the bug.
> Attached is a simple program that does that, and indeed has the same
> issue.

Oh, OK.
So here is another test case, which is maybe easier to debug (less libraries
involved). It uses getcwd() which calls malloc.
On a i386:
this is my malloc
On sgimips:
real malloc called

Manuel Bouyer <>
     NetBSD: 24 ans d'experience feront toujours la difference

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="main.c"

#include <malloc.h>
#include <stdio.h>
#include <unistd.h>

main(int argc, char **argv)
	char *p;
	p = getcwd(NULL, 0);
	if (p != NULL) {
		printf("real malloc called\n");

void *
malloc(size_t size) {
	char *s = "this is my malloc\n";
	write(0, s, strlen(s));
	return NULL;