[uClibc]mmap bug in uClibc 0.9.19 on mips

Sirotkin, Alexander demiurg at ti.com
Thu Mar 6 15:16:44 UTC 2003


Just tried uClibc on our mips platform and discovered
the mmap bug.

I'm still not sure what exactly happens, mmap() returns
a valid address but it does not point to a correct physical
memory address.

The same code works on 0.9.16 and with glibc.


Here is the example code (it will only work if you have
some hardware on the hardcoded address) :

#include <stdio.h>
#include <sys/mman.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

typedef struct {
  int mem, reg, mem_size, reg_size;
} tiwlan_mem_base_t;

int main() {
	tiwlan_mem_base_t mem_base;
	int mem_fd, f;
	int  AcxRegAddr;

	if ((mem_fd = open("/dev/kmem", O_RDWR)) < 0) {
		puts("DAMN 1");
		return -1;
	}

	mem_base.reg = 0xbc000000;
	mem_base.reg -= 0xA0000000;
	
	AcxRegAddr = (int)mmap(NULL, mem_base.reg_size, PROT_READ | 
PROT_WRITE, MAP_SHARED, mem_fd, mem_base.reg);
	printf("mmap() returned : %p\n", AcxRegAddr);
	f = *(volatile int *)(AcxRegAddr+0x0900);

	printf("F : %#x\n", f);

	return 0;
}

-- 
Alexander Sirotkin
SW Engineer

Texas Instruments
Broadband Communications Israel (BCIL)
Tel:  +972-9-9706587
________________________________________________________________________
"Those who do not understand Unix are condemned to reinvent it, poorly."
       -- Henry Spencer



More information about the uClibc mailing list