[coreboot] why my program segmentation fault?

George Danchev danchev at spnet.net
Mon Jul 14 12:32:56 CEST 2008


Quoting Star Liu <minxinjianxin at gmail.com>:

> I wrote a program to copy the memory content of FFFF0000-FFFFFFFF to a
> file, but it says "Segmentation fault", (i use AMD64 lenny, so the
> address is long), how could i fix it? thanks!

you should only fclose() if Memory != NULL, so your function would be  
better off like this:

void CopyMemoryToFile(char* FilePath, long StartAddress, long OffSet)
{
    FILE* Memory;
    Memory=fopen (FilePath, "w");
    if(Memory!=NULL)
    {
       void* Start;
       Start=StartAddress;
       fwrite(Start, 1, OffSet, Memory);
       fclose(Memory);
    }
}








More information about the coreboot mailing list