I have some attribute((used, section ... )) codes, so I need modify the main.lds file.
run ld --verbose >> main.lds to generate the default main.lds file. It's 64 bits version, I need 32 bits version.
modify main.lds
OUTPUT_FORMAT(pei-i386) .bss BLOCK(section_alignment) : { *(.app_init.0) *(.app_init.1) *(.app_init.2) ....
modify tasks.json file in vscode.
"command": "gcc.exe", "args": [ "-g", "-m32", "-fshort-enums", "${workspaceFolder}\\*.c", "'-Wl,-Tmain.lds'", "'-Wl,-Map=${workspaceFolder}\\obj\\${workspaceRootFolderName}.map'", "-o", "${workspaceFolder}\\obj\\${workspaceRootFolderName}.exe", ],
then I get 32bits main.exe, but it cannot run:
Thread 1 received signal SIGSEGV, Segmentation fault. 0xffffffff in ?? ()
Did I miss something in the main.lds file?
( 1. if I don't modify main.lds and delete "-m32" in tasks.json, I can get 64bit main.exe and it run correctly. and my sections code also run correctly. 2. if I delete "'-Wl,-Tmain.lds'" in tasks.json, I can get 32bit main.exe with default lds file and it run correctly. but my sections code don't run correctly. )
need help. thank you very much.