DSPRelated.com
Forums

symbol overloading in CCS 3.1?

Started by Clem Taylor October 20, 2005
Hi,

I'm trying to overload _assert() with a version that calls my own
printf-like routine instead of fprintf.

I'm getting a 'defined multiple times' linker error between my .obj
file and assert.obj in rts6400.lib.

I tried putting my .obj first in the link order and adding -priority
to the linker options, but it seems rts6400.lib is still being linked
ahead of my .obj and -priority doesn't effect the link error.
rts6400.lib is being included from DSB/BIOS .cmd file which is last in
the argument list. I also tried using -u on the command line and in my
.cmd file, without any luck.

I'd really like to avoid having to rebuild rts6400.lib from source
(maintenance headache). Any ideas what the proper technique for
overloading a symbol at link time?

Thanks,
Clem


Hi,
 
If you are using DSP/BIOS, rts6400.lib is included automatically. If you added this file manually as well then that might be causing the problem.
 
Regards,
 
Ilgin

Clem Taylor <c...@gmail.com> wrote:
Hi,

I'm trying to overload _assert() with a version that calls my own
printf-like routine instead of fprintf.

I'm getting a 'defined multiple times' linker error between my .obj
file and assert.obj in rts6400.lib.

I tried putting my .obj first in the link order and adding -priority
to the linker options, but it seems rts6400.lib is still being linked
ahead of my .obj and -priority doesn't effect the link error.
rts6400.lib is being included from DSB/BIOS .cmd file which is last in
the argument list. I also tried using -u on the command line and in my
.cmd file, without any luck.

I'd really like to avoid having to rebuild rts6400.lib from source
(maintenance headache). Any ideas what the proper technique for
overloading a symbol at link time?

Thanks,
Clem
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c6x/

<*> To unsubscribe from this group, send an email to:
c...@yahoogroups.com

<*


Yahoo! FareChase - Search multiple travel sites in one click.

On 10/21/05, Ilgin Safak <ilginsafak@ilgi...> wrote:
> If you are using DSP/BIOS, rts6400.lib is included automatically. If you
> added this file manually as well then that might be causing the problem.

The rts6400.lib is being included from the *cfg.cmd file that is
generated from the .tcf file. The only libraries I've manually added
is the csl and the fastrts (for fast floats) libraries. On the command
line, this .cmd file is mentioned last and the .obj with my
implementation of assert() is earlier in the command line. I assumed
that with the -priority option, the linker would take my version
before the version in the .cmd file. However, it still generates the
'defined multiple times' error. Does the '-priority' option only apply
to libraries and not objects?

Any ideas how to get this to work?
Clem


Clem,

Please see my comments below for a solution.

mikedunn

--- Clem Taylor <clem.taylor@clem...> wrote:

> On 10/21/05, Ilgin Safak <ilginsafak@ilgi...>
> wrote:
> > If you are using DSP/BIOS, rts6400.lib is included
> automatically. If you
> > added this file manually as well then that might
> be causing the problem.
>
> The rts6400.lib is being included from the *cfg.cmd
> file that is
> generated from the .tcf file. The only libraries
> I've manually added
> is the csl and the fastrts (for fast floats)
> libraries. On the command
> line, this .cmd file is mentioned last and the .obj
> with my
> implementation of assert() is earlier in the command
> line. I assumed
> that with the -priority option, the linker would
> take my version
> before the version in the .cmd file. However, it
> still generates the
> 'defined multiple times' error. Does the '-priority'
> option only apply
> to libraries and not objects?
>
> Any ideas how to get
> this to work?
> Clem
All you need to do is put your code in an archive
[library].

From TI help file - sometimes useful :-)
The -priority option is used to provide an alternate
search mechanism for libraries. priority causes each
unresolved reference to be satisfied by the first
library that contains a definition for that symbol.

This option is useful for libraries that want to
provide overriding definitions for related sets of
functions in other libraries without having to provide
a complete version of the whole library.

For example, suppose you want to override versions of
malloc and free defined in the rts6200.lib without
providing a full replacement for rts6200.lib. Using
-priority and linking your new library before linking
rts6200.lib guarantees that all references to malloc
and free resolve to the new library.
This option is intended to support linking programs
with DSP/BIOS where situations like the one
illustrated above occur.

> c6x-unsubscribe@c6x-...



On 10/21/05, Mike Dunn <mike-dunn@mike...> wrote:
> All you need to do is put your code in an archive [library].
>
> From TI help file - sometimes useful :-)
> The -priority option is used to provide an alternate
> search mechanism for libraries. priority causes each
> unresolved reference to be satisfied by the first
> library that contains a definition for that symbol.

Hmm... After posting my earlier message I moved my implementation of
_assert() into a library. This didn't seem to help at all. It still
complains with the same error.

>> error: symbol __assert is defined multiple times: overload.obj
(.../support.lib) and assert.obj
(C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)

The automatically generated Release.lkf file shows that '-priority'
option is specified and that my library is included prior to the
DSP/BIOS .cmd file.

The *cfg.cmd file also includes the -priority option.

Has anyone used '-priority' to replace a symbol with CCS 3.1? I'm
wondering if part of the problem is that rts6400.lib is included from
the *cfg.cmd. If I add -lrts6400.lib to the command line, then I get
additional 'defined multiple times' errors for _c_int00 and __stack...

Any ideas,
Clem


Clem,

My comments are below...

--- Clem Taylor <clem.taylor@clem...> wrote:

> On 10/21/05, Mike Dunn <mike-dunn@mike...>
> wrote:
> > All you need to do is put your code in an archive
> [library].
> >
> > From TI help file - sometimes useful :-)
> > The -priority option is used to provide an
> alternate
> > search mechanism for libraries. priority causes
> each
> > unresolved reference to be satisfied by the first
> > library that contains a definition for that
> symbol.
>
> Hmm... After posting my earlier message I moved my
> implementation of
> _assert() into a library. This didn't seem to help
> at all. It still
> complains with the same error.
>
> >> error: symbol __assert is defined multiple
> times: overload.obj
> (.../support.lib) and assert.obj
> (C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)
>
> The automatically generated Release.lkf file shows
> that '-priority'
> option is specified and that my library is included
> prior to the
> DSP/BIOS .cmd file.
>
> The *cfg.cmd file also includes the -priority
> option.
>
> Has anyone used '-priority' to replace a symbol with
> CCS 3.1? I'm
> wondering if part of the problem is that rts6400.lib
> is included from
> the *cfg.cmd. If I add -lrts6400.lib to the command
> line, then I get
> additional 'defined multiple times' errors for
> _c_int00 and __stack...

I would suggest a more controled test to identify the
source of the problem - try using your 'assert.lib'
with a simple 'hello.world' type of test case to very
that '-priority' works as advertised. If this works
then you know that the issue lies in the 'DSP/BIOS
maze'.
mikedunn
>
> Any ideas,
> Clem > c6x-unsubscribe@c6x-... >




Clem,

I was looking up something else today and 'stumbled'
onto the following [it sounded good to me]...

It is recommended to use the DSP/BIOS library version
of malloc, free, memalign, calloc and realloc within
DSP/BIOS applications. When you are not referencing
these functions directly in your application but call
another run-time support function which references one
or more of them, add -u _symbol, (for example, -u
_malloc) to your linker options. The -u linker option
introduces a symbol, such as malloc, as an unresolved
symbol into the linkers symbol table. This causes the
linker to resolve the symbol from
the DSP/BIOS library rather than the run-time support
library. If in doubt, you can examine your map file
for information on the library sources of your
application. mikedunn
--- Clem Taylor <clem.taylor@clem...> wrote:

> On 10/21/05, Mike Dunn <mike-dunn@mike...>
> wrote:
> > All you need to do is put your code in an archive
> [library].
> >
> > From TI help file - sometimes useful :-)
> > The -priority option is used to provide an
> alternate
> > search mechanism for libraries. priority causes
> each
> > unresolved reference to be satisfied by the first
> > library that contains a definition for that
> symbol.
>
> Hmm... After posting my earlier message I moved my
> implementation of
> _assert() into a library. This didn't seem to help
> at all. It still
> complains with the same error.
>
> >> error: symbol __assert is defined multiple
> times: overload.obj
> (.../support.lib) and assert.obj
> (C:/CCStudio_v3.1/C6000/cgtools/lib/rts6400.lib)
>
> The automatically generated Release.lkf file shows
> that '-priority'
> option is specified and that my library is included
> prior to the
> DSP/BIOS .cmd file.
>
> The *cfg.cmd file also includes the -priority
> option.
>
> Has anyone used '-priority' to replace a symbol with
> CCS 3.1? I'm
> wondering if part of the problem is that rts6400.lib
> is included from
> the *cfg.cmd. If I add -lrts6400.lib to the command
> line, then I get
> additional 'defined multiple times' errors for
> _c_int00 and __stack...
>
> Any ideas,
> Clem > c6x-unsubscribe@c6x-... >