Hi, all

=============================================
There's a linker commands in the Kbuild like that:

cmd_link_o_target = $(if $(strip $(obj-y)),\
        $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^), \
        rm -f $@; $(AR) rcs $@)

Descriptions from GCC:
-r
--relocateable
Generate relocatable output-i.e., generate an output file that can in turn 
serve as input to ld. This is often called partial linking. As a side 
effect, in environments that support standard Unix magic numbers, this 
option also sets the output file's magic number to OMAGIC. If this option is 
not specified, an absolute file is produced. When linking C++ programs, this 
option will not resolve references to constructors; to do that, use '-Ur'.
When an input file does not have the same format as the output file, partial 
linking is only supported if that input file does not contain any 
relocations.
Different output formats can have further restrictions; for example some 
a.outbased formats do not support partial linking with input files in other 
formats
at all.
This option does the same thing as '-i'.

As a result, the "ld -r -o $@ $^" command links the $^ object files into a 
single object file $@.
=============================================

Could this style of link operation be implemented in SDCC?

=============================================
Currently, I'm using a stupid command like:

cmd_link_o_target = rm -f $@; $(AR) -Sqc $(EXTRA_ARFLAGS) $@ \
 $(filter-out %built-in.lib, $(filter $(obj-y), $^)) \
 $(foreach l,$(filter %built-in.lib, $(filter $(obj-y), $^)), \
 $(foreach f,$(shell $(AR) -t $(l)), \
 $(addprefix $(subst built-in.lib,,$(l)), $(f))))

As I know (but may wrong), sdcc could not link object files with the same 
basename but different directory prefix, I have to first create static 
libraries (built-in.lib) for each bundle of object files in the same 
directory.  The problem is how to put the object files linked in the 
subdirectories' built-in.lib into the current directory's built-in.lib.  The 
stupid command can extract the object files names of the subdirectories' 
built-in.lib, and link them along with the current directory's object files 
into a single static built-in.lib.  In this way, I could finally link all of 
such libraries together but directory depth are limited.
=============================================

Are there any smarter SDCC methods to implement the previous style link 
operation?  This is quite useful for organizing large C projects.

Best regards/ZETALOG


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to