Quantcast
Viewing all articles
Browse latest Browse all 22088

simple linker.ld file broke the executable MinGW

I have tried a simple linker script in MinGW using the following commands
gcc -Wall -c boot.c
ld boot.o -o boot.exe -T linker.ld

boot.c contains

int my_main(void){    return 0x1000;}

linker.ld contains

ENTRY(my_main)SECTIONS{    .text : { *(.text) }    .data : { *(.data) }    .bss : { *(.bss) }}

the linker output is warning warning: cannot find entry symbol my_main; defaulting to 00000000and the virtual addresses of the sections are weird values:

C:\src>objdump -h boot.exeboot.exe:     file format pei-i386Sections:Idx Name          Size      VMA       LMA       File off  Algn  0 .text         0000000c  00000000  00000000  00000200  2**2                  CONTENTS, ALLOC, LOAD, READONLY, CODE  1 .rdata        00000024  00001000  00001000  00000400  2**2                  CONTENTS, ALLOC, LOAD, READONLY, DATA  2 .eh_fram      00000038  00002000  00002000  00000600  2**2                  CONTENTS, ALLOC, LOAD, READONLY, DATA

and when i try to execute it, windows says "This app can't run in your PC"


Viewing all articles
Browse latest Browse all 22088

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>