EmbDev.net

Forum: ARM programming with GCC/GNU tools C++ Linker Problem


von Matthias Wilde (Guest)


Rate this post
useful
not useful
Hello,

I use NutOS (see http://www.ethernut.de) and using C++. They provide
linker scripts but I have problems using linking C++ objects. Linker
Script is the following. To be honest, I have no idea of linker scripts,
this one is used:

http://cvs.sourceforge.net/viewcvs.py/ethernut/nut/arch/arm/ldscripts/at91_ram.ld?rev=1.1&view=markup


I get the following error message:

winarm\bin\..\lib\gcc\arm-elf\4.0.2\..\..\..\..\arm-elf\bin\ld.exe:
error: no
memory region specified for loadable section
`.gnu.linkonce.t._ZN15TemplateCoun
erIhEC2Ev'


Any hints are welcome.

Thank you in advance


Matthias

von Martin Thomas (Guest)


Rate this post
useful
not useful
Matthias Wilde wrote:

> I use NutOS (see http://www.ethernut.de) and using C++. They provide
> linker scripts but I have problems using linking C++ objects. Linker
> Script is the following. To be honest, I have no idea of linker scripts,
> this one is used:
>
> 
http://cvs.sourceforge.net/viewcvs.py/ethernut/nut/arch/arm/ldscripts/at91_ram.ld?rev=1.1&view=markup
>
>
> I get the following error message:
>
> winarm\bin\..\lib\gcc\arm-elf\4.0.2\..\..\..\..\arm-elf\bin\ld.exe:
> error: no
> memory region specified for loadable section
> `.gnu.linkonce.t._ZN15TemplateCoun
> erIhEC2Ev'

The linker-script from the ethernet-cvs seems to be a "c-only" script. I
have some ideas about what has to be added/changed (i.e. the
linkonce-entries and ctor/dtor-sections and data) but currently no time
to create a modified version. Maybe later today or tomorrow. The
startup-code has to be modified too to call the ctors before "branch to
main()".

Martin Thomas

von Matthias Wilde (Guest)


Rate this post
useful
not useful
Hi Martin,

yes, you are right, it is running for C. However I tried to expand the
script for C++, but as I said I have no idea how. However, if you could
insert the missing parts that would be great. Or if you could just give
me some hintswhere I can get information or an example how a C++ linker
script should look like - that would be also very helpful.

Thank you very much

Matthias




Martin Thomas wrote:

> The linker-script from the ethernet-cvs seems to be a "c-only" script. I
> have some ideas about what has to be added/changed (i.e. the
> linkonce-entries and ctor/dtor-sections and data) but currently no time
> to create a modified version. Maybe later today or tomorrow. The
> startup-code has to be modified too to call the ctors before "branch to
> main()".
>
> Martin Thomas

von Matthias Wilde (Guest)


Rate this post
useful
not useful
Hello again,

I think I can solve it, I just looked for the linker default script. I
try tonight and let you know.

Matthias

von Matthias Wilde (Guest)


Rate this post
useful
not useful
Ok, after two nights, I could not solve the problem. Now I get unresoved
functions of NutOS. To be honest, linker scripts are more complicated
than I expected.....

I have to wait for an expert ....


Best regards


Matthias

von Martin Thomas (Guest)


Rate this post
useful
not useful
Matthias Wilde wrote:

I have modified the ethernut/NutOS-Linker-Script. Completly untested but
should give an idea. The script will be available for some days on:
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/winarmtests/

> Now I get unresoved functions of NutOS.

Maybe a "C/C++" symbol-name problem here. As far as I know the NutOS
header-files do not include an extern "C"-Wrapper like

#ifdef __cplusplus
extern "C" {
#endif

[...]

#ifdef __cplusplus
}
#endif

At least I do not see them in the few headers files which I have read in
the CVS. Without this "wrappter" there will be unresolved externals when
the NutOS-libraries are compiled with the C-compiler and the user
program is compiled with the C++-compiler.


For a test you could try

extern "C" {
#include "a_NutOS_include_file.h"
#include "another_NutOS_include_file.h"
}

in your C++ source-files.

Hope this helps
Martin Thomas

von Matthias Wilde (Guest)


Rate this post
useful
not useful
Hello Martin,

thnak you very much for the linker script. I will test it end of this
week. The extern "C" problem I know and I allready included the header
files like you recommended. However, might be an other issue. I try your
linker script and let you know the results.


Best regards

Matthias

von Matthias Wilde (Guest)


Rate this post
useful
not useful
Hello Martin,

Ok I promised a several weeks ago "I will test it end of the week".....

I tested it now and your suggestion works for me perfect.

THANK YOU VERY MUCH!!

One last question. Can we use your additional changes without any
restrictions / copyright issues within Nut/OS?

Best regards


Matthias

von Martin Thomas (Guest)


Rate this post
useful
not useful
Matthias Wilde wrote:
> Hello Martin,
>
> Ok I promised a several weeks ago "I will test it end of the week".....
>
> I tested it now and your suggestion works for me perfect.
>
> THANK YOU VERY MUCH!!

I'm glad that I could help you.

>
> One last question. Can we use your additional changes without any
> restrictions / copyright issues within Nut/OS?

I have got my information from the sources given in the modified
linker-script and a little "try and error" with my gcc-C++-test on the
LPC2000. I don't think that there are any restrictions or
copyright-issues since "it's just the way it has to be done". It would
be nice if you or Harald could keep my name somewhere in the header of
the file.

Martin Thomas

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.