EmbDev.net

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


Author: Matthias Wilde (Guest)
Posted on:

Rate this post
0 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...


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

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 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...
>
>
> 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

Author: Matthias Wilde (Guest)
Posted on:

Rate this post
0 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

Author: Matthias Wilde (Guest)
Posted on:

Rate this post
0 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

Author: Matthias Wilde (Guest)
Posted on:

Rate this post
0 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

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 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...

> 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

Author: Matthias Wilde (Guest)
Posted on:

Rate this post
0 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

Author: Matthias Wilde (Guest)
Posted on:

Rate this post
0 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

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.