Re: Modules and ld command

From: archibal (glop00.5.archibald_at_spamgourmet.com)
Date: 09/19/03


Date: 19 Sep 2003 16:29:54 GMT


Kasper Dupont wrote:

>>So I can do : ld -r -o SingleModule.o MyModule1.o MyModule2.o

> I don't think you can link two modules that way. Each module would have
> an initialization function, I don't think the final module can have
> multiple initialization functions. You can build a module by linking
> multiple object files with ld, but those object files wouldn't be
> modules themselves.
Ok, in this case the only problem I'll get if I'm doing this is modprobe won't
load the SingleModule.o and will show me some errors, am i right ?

 
>
>>I would like to know if this last command ( ld ...) will give to me the same
>>result as to have joined the source code of the two modules.
>
>
> Not necesarilly. For example all preprocessing is done independently
> before compiling, so a define in one source file is not going to be
> present when compiling the other.
I don't think I'll get this sort of problems in the way I compile my source but
I've to keep in my mind your pertinent remark.

> Also notice that the scope of static
> functions and variables is the object file. A static function in one
> object file cannot be accessed by the other, that would be possible if
> you joined the sources before compiling.
I would have thought that ld command above would have allow to avoid
this problem so I've to consider that this ld command build one object file
( *.o) from other object files and this one object file is only a concatenation
of object files.

I tried something and the result seems to be not in keeping with what I've just
said :

if the size of MyModule1.o = 1000 and the size of MyModule2.o = 500, the ld
command above don't give me SingleModule.o with a size of 1500, so it's possible
to think that ld doesn't just do a concatenation of MyModule(x).o

If I include the same variable in MyModule1.o and MyModule2.o, the ld command
will stop creating SingleModule.o with an error which is multiple definition of .
.., so again I don't think ld command makes just a concatenation of modules.

I should like to have opinions.

Thanks.

-- 
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr
http://forums.club-internet.fr/


Relevant Pages

  • Re: linkage problems when building a VC7.1 project from the command line
    ... at least one problem seems to be that your link command does not take object files as inputs. ... If I look at a random link command on my system, it contains a list of object files to link together. ... Creating temporary file "c:\timer\Debug\RSP000007.rsp" with contents ... What are these .rsp (linker response) files and how may I re-create them on the command line? ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Modules and ld command
    ... > My goal would be to have only one single module to load with modprobe ... an initialization function, I don't think the final module can have ... multiple object files with ld, but those object files wouldn't be ... present when compiling the other. ...
    (comp.os.linux.development.system)
  • Re: How to list objects files in an executable
    ... try runnng the nm command (the name nm stands for "name" - since it ... all the object files linked into this executable. ... source files that were used. ... This is a signature virus. ...
    (comp.unix.programmer)
  • problems applying property pages in VC2005
    ... I'm having some problems applying the property pages ... to a project the project does'nt generate any object files. ... Creating temporary file ... Creating command line "link.exe ...
    (microsoft.public.vc.ide_general)
  • Re: static GtkAda
    ... > the libs below (let's say libz) to the beginning of the list the ... previously undefined symbol, AFAIK. ... references in libraries listed later in the command line cannot be ... resolved by object files that have already been skipped. ...
    (comp.lang.ada)