I have study makefile projec. I am using the gnu gcc and as linker, I use the gcc with the following argument:
linkerCmdLine=$(exe) -Wl,--start-group -nostdlib -Map=test_mapfile.map -l:libc.a -l:libgcc.a -l:libm.a -Wl,--end-group -o $(output)
During the linking process, the linker does not use all of this flags: The flag -Map=test_mapfile.map
is not used.
Why??
There is a project settings file and in this one is also stored the linker settings.
\“linkerCmdLine\\=$(exe) -Wl, --start-group -nostdlib -Map\\=./99_output/PUZ_GPF.map --gc-sections -l\\:libc.a -l\\:libgcc.a -l\\:libm.a -Wl,--end-group -o $(output)\”
How must I store the settings correct?
Edited:
With the the map file works fine, but I have actually problem with the linker file. I use only the following flag:
"linkerCmdLine=$(exe) -Wl, --script=C:/workspace/test_project/test_linker_file.ld -static -o $(output)”
I get this error in the console window:
arm-none-eabi-gcc.exe: error: unrecognized command line option '--script=C:/workspace/test_project/test_linker_file.ld'
I don't understand why, because the map file and the .ld file belong to the linker flags.
The -Wl,
prefix only passes the current argument, with commas separating linker arguments. So in order to pass -z defs
, you would use -Wl,-z,defs
.
This mechanism only works for true flags, ie when the position in the command line is irrelevant. The -l
parameters are not flags, and the gcc compiler driver collects them into a separate list and passes them in a single block.
So this technique doesn't work for the exact commandline you want. On the other hand, the -nostdlib
inhibits the -lc -lgcc -lm
that would be the default.
Normally there is a provision in the gcc specs (the script for the compiler driver) to use --start-group
and --end-group
around the standard libraries when linking statically (which appears to be what you want to do).
So I think that
linkerCmdLine=$(exe) -Wl,-Map=test_mapfile.map -static -o $(output)
should work for your case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.