PropGCC: What is the "-r" flag?
DavidZemon
Posts: 2,973
in Propeller 1
What does the "-r" flag do when invoking PropGCC? I noticed that it is used in the Makefile for cog_c_toggle in the PropGCC demos here.
toggle_1.o: toggle_cog.c $(CC) -r -Os -mcog -o $@ $<
Comments
http://uw714doc.sco.com/en/man/html.1/ld.1.html
dgately
As you know, LMM and COG code need different libraries, since they have different calling conventions and since even some internal functions like multiply will end up in different places inside the COGs. So we need to resolve all the library symbols in the COG code so they don't try to use LMM libraries. One way to do that is to completely compile the COG code into a binary blob. However, that means the COG and LMM can't share any symbols at all, and sometimes we may want to e.g. refer to a variable in hub memory from both COG and LMM. To do that we need to do a partial link on the COG side, resolving as many symbols as possible but still allowing references to outside symbols as well.
There's another wrinkle as well, which is that we don't want the symbols in the COG object to satisfy any LMM unresolved library calls. So the Makefile invokes objcopy with --localize-text to make all the code symbols in the COG be static. (The objcopy also has options to rename the .text section to .toggle.cog so the linker can do its overlay magic.)