Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Real-Time Software Components (RTSC) » problem when using filter for linking
problem when using filter for linking [message #664142] Thu, 07 April 2011 15:39 Go to next message
Patrick Geremia is currently offline Patrick GeremiaFriend
Messages: 79
Registered: July 2009
Member
I have defined a filter for the linking to allow me to work with
parasoft insure++). The filter is as follows

>>
function link(container, cfgBase, prog, objList, linkArgs, result)
{
result.cmds = "insure " + result.cmds;
}
<<

I believe there is a bug because the insure command is prepended to the
RM command and not to the gcc command as you can see in the below
extract from package.mak

>>
package/cfg/ti_wbi_umts_ractest_ractb_nyquist_insure_86U_x86 U.o86U
package/cfg/ti_wbi_umts_ractest_ractb_nyquist_insure_86U/src /main.o86U :
| package/cfg/ti_wbi_umts_ractest_ractb_nyquist_insure_86U_x86 U.xdl
ti_wbi_umts_ractest_ractb_nyquist_insure_86U.x86U:
$(RM) $@
@$(MSG) lnk86U $@ ...
insure $(RM) $(XDCCFGDIR)$@.map
$(gnu.targets.Linux86.rootDir)//bin/gcc -m32 -lm -o $@
package/cfg/ti_wbi_umts_ractest_ractb_nyquist_insure_86U_x86 U.o86U
package/cfg/ti_wbi_umts_ractest_ractb_nyquist_insure_86U/src /main.o86U
package/cfg/ti_wbi_umts_ractest_ractb_nyquist_insure_86U_x86 U.xdl
-Wl,-Map=$(XDCCFGDIR)/$@.map -lstdc++ -L$(gnu.targets.Linux86.rootDir)/lib
<<

I use XDCTools version 3_20_08_88
Re: problem when using filter for linking [message #664171 is a reply to message #664142] Thu, 07 April 2011 17:38 Go to previous messageGo to next message
Sasha Slijepcevic is currently offline Sasha SlijepcevicFriend
Messages: 90
Registered: July 2009
Member
Patrick,
any target can return more than one command line from link(), and many targets have 'rm' command is a part of the return value.

I solved the similar problem by looking for a string that shows up in the linker command line:
    var rescmd = "";
    for (var i = 0; i < result.cmds.length; i++) {
        if (result.cmds[i].match('lnk')) {
            rescmd = rescmd + "date " + result.cmds[i] + "\n";
        }
        else {
           rescmd = rescmd + result.cmds[i] + "\n";
        }
    }
    return (rescmd);

In your case, 'lnk' could be some other string ('gcc').

[Updated on: Thu, 07 April 2011 17:39]

Report message to a moderator

Re: problem when using filter for linking [message #666418 is a reply to message #664171] Wed, 20 April 2011 11:50 Go to previous message
Patrick Geremia is currently offline Patrick GeremiaFriend
Messages: 79
Registered: July 2009
Member
ok. Thanks. I got it to work.

The filter is desired to wotk with Parasoft insure++.
Here is my final version in case someone is interested.

============================================================ ============
function compile(container, target, goal, compArgs, result)
{
/*
print("compile filter ...");
print(" container: " + container);
print(" target : " + target.name);
print(" goal : " + goal);
print(" source : " + compArgs.srcPrefix + compArgs.base +
compArgs.srcSuffix);
*/
/* pre-pend a pre-processing step to each compile */
result.cmds = "insure " + result.cmds;
}


function link(container, cfgBase, prog, objList, linkArgs, result)
{
/*
print("link filter ...");
print(" container: " + container);
print(" cfg : " + cfgBase);
print(" prog : " + prog.name);
print(" objs : " + objList);
print(" linkArgs : " + linkArgs.files);
*/
var xdlFile;
var files=linkArgs.files.split(" ");
for (var i=0; i<files.length; i++)
{
if (files[i].match(".xdl"))
/* found xdl file */
{
xdlFile=files[i];
}
}

var cmdLines=result.cmds.split("\n");
var resLines = [];
for (var i = 0; i < cmdLines.length; i++)
{
print("old line = " + cmdLines[i]);
if (cmdLines[i].match("gcc"))
/* found gcc command line */
{
var cmds=cmdLines[i].split(" ");
var newCmd="";
for (var j = 0; j < cmds.length; j++)
{
if (cmds[j].match(xdlFile))
{
newCmd = newCmd + " -Xlinker " + cmds[j] ;
}
else
{
newCmd = newCmd + " " + cmds[j] ;
}
}
resLines[i]="insure " + newCmd;
}
else
{
resLines[i] = cmdLines[i] ;
}
print("new line = " + resLines[i]);
}

result.cmds=resLines.join("\n");
}
============================================================ ============

-------- Original Message --------
Subject: Re: problem when using filter for linking
From: Sasha Slijepcevic <sascha@ti.com>
To:
Date: Thu Apr 07 2011 19:38:54 GMT+0200 (CET)

> Patrick,
> any target can return more than one command line from link(), and many
> targets have 'rm' command is a part of the return value.
>
> I solved the similar problem by looking for a string that shows up in
> the linker command line:
>
> var rescmd = "";
> for (var i = 0; i < result.cmds.length; i++) {
> if (result.cmds[i].match('lnk')) {
> rescmd = rescmd + "date " + result.cmds[i] + "\n";
> }
> else {
> rescmd = rescmd + result.cmds[i] + "\n";
> }
> }
> return (rescmd);
>
> In your case, 'lnk' could be some other string.
Previous Topic:XDCtools for mac
Next Topic:#ifdef for .cfg files?
Goto Forum:
  


Current Time: Mon Dec 22 12:05:22 GMT 2014

Powered by FUDForum. Page generated in 0.05462 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software