objdump has bug

objdump has bug

2015/04/11 GKD 0

objdump command has bug, i tried to use this command “objdump -dS kernel” to display mixed assembly and c code. But objdump has bug, it dump the same piece of c source code in two different memory locations. I double checked the dwarf data, nothing wrong. On more prove the dwarf is correct, my GKD debugger can dump the source correctly.

objdump has bug

objdump has bug

gkd is better than objdump

below is the code:

void *kmalloc2(unsigned int virtualAddress, unsigned int physicalAddress,
                unsigned size) {
        unsigned int PDselector = virtualAddress >> 22;
        unsigned int PTselector = (virtualAddress >> 12) & 0x3ff;

        // All the kernel's Page Directory is already linked to corresponding page table, so we don't need to create page directory, we just ended to fill in the free physical address into the page tables
        unsigned int freeContinuousPhysicalAddress = physicalAddress;

        //Page_Directory *pageDirectories=(Page_Directory *)0x1100000;
        unsigned int numberOfPage = (size % 4096 == 0) ? size / 4096 : size / 4096
                        + 1;
        struct Page_Table *pageTablesBase = (struct Page_Table *) 0x1101000
                        + PTselector + PDselector * 1024;
        unsigned int pageNo;
        for (pageNo = 0; pageNo < numberOfPage; pageNo++) {
                pageTablesBase->pageTableBase = (freeContinuousPhysicalAddress
                                + (pageNo * 4096)) >> 12;
                pageTablesBase++;
        }
        return (void *) virtualAddress;
}

I compile it by:

system.o : system.c
        $(CC) -I$(NEWLIB_DIR)/include -c -g $? -ffreestanding -Wall -Wno-long-long -O2 -fno-exceptions -fno-builtin -o $@