2010-07-08 04:56:49     strange issue with a function invocation

Document created by Aaronwu Employee on Aug 22, 2013
Version 1Show Document
  • View in full screen mode

2010-07-08 04:56:49     strange issue with a function invocation

Dimitar Penev (BULGARIA)

Message: 91033   

 

Hi Guys,

 

I am observing something pretty strange to me.

I am tring to link few object files (defined by a few C files) into a shared library. I am using bfin-linux-uclibc-gcc v4.1.2

 

In one of the c file I have hdlc_tx_init finction defined. This function is invoked from other C file.  The compilation and linking doesn't report  warrnings or errors  but the invokation of this function seems to not happen. (The functionality of the libarray changes if I substitute the function invocation line with the content of this function. Also prints inside the function doesn't print anything)

 

Initially I concluded  that i have stack  issue  but increasing the stack size and adding -mstack-check-l1 doesn't change anything.

 

If I change the name of the function however (to hdlc_tx_init1 ) the invocation is happening.

 

Grepping for hdlc_tx_init shows a strict member with this name but I don't think it is related.

In the intermediate file *.i I see the function properly defined without name mangling

objdump of the so library shows  _hdlc_tx_init symbol

 

 

The object files are compiled using flags:

-std=gnu99 -save-temps -g  -Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64

 

then the linking flags are:

-std=gnu99 -g -save-temps -Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64  -shared -Xlinker -lm -lz -lssl -lcrypto

 

 

 

I am not sure what is the best way to approach problems like this? What do you think should I check?

 

Thank you

Dimitar

QuoteReplyEditDelete

 

 

2010-07-08 12:41:51     Re: strange issue with a function invocation

Mike Frysinger (UNITED STATES)

Message: 91063   

 

linking libraries with stack checking flags doesnt matter.  only the main executable matters.

 

look at the objdump output of the function in question and make sure it has a reference to the function you care about

 

when you look at the .i file where the function call is made, is it still correct or has it been macroed away to smething else

 

you can use -dD when creating the .i files to retain all macros

QuoteReplyEditDelete

 

 

2010-07-08 16:25:47     Re: strange issue with a function invocation

Dimitar Penev (BULGARIA)

Message: 91078   

 

Hi Mike,

 

Thank you for your reply.

 

The invocation from the i file:

hdlc_tx_init(&state->txctrl, 40, state->txcmdbuf, state->txcmdp);

 

-------------------------------------------------------------------------

The definition of the function from the i file:

void hdlc_tx_init(hdlc_tx_state *state, int prlen, unsigned short *buf, int len) {

bzero(state, sizeof (hdlc_tx_state));

state->cmdbuf = buf;

state->cmdlen = len;

state->prlen = prlen;

state->cmdb = 0;

state->bitp = 0;

state->run1 = state->flag1 = 0;

state->cmdp = -1;

return;

}

 

--------------------------------------------------------------------------

Invocation from the s file:

        R1 = [FP+12];

        R0 = 592 (X);

        R2 = R1 + R0;

        R1 = [FP+12];

        R0 = 632 (X);

        R3 = R1 + R0;

        P2 = [FP+12];

        R0 = [P2+1656];

        [SP+12] = R0;

        R0 = R2;

        R1 = 40 (X);

        R2 = R3;

        P3 = P5;

        call _hdlc_tx_init;

 

--------------------------------------------------------------------------

The begining of the definition of the function  from the s  file:

.global _hdlc_tx_init;

.type _hdlc_tx_init, STT_FUNC;

_hdlc_tx_init:

.LFB7:

        .loc 1 130 0

        LINK 0;

.LCFI5:

        [FP+8] = R0;

...

---------------------------------------------------------------------------

Dump of the symbol from the so library:

bfin-linux-uclibc-objdump -T build_ip04/root/lib/libt30.so | grep hdlc_tx_init

000059c0 g    DF .text  00000082  Base        _hdlc_tx_init

 

---------------------------------------------------------------------------

It looks normal to me.

 

Best Regards

Dimitar

QuoteReplyEditDelete

 

 

2010-07-08 16:39:16     Re: strange issue with a function invocation

Mike Frysinger (UNITED STATES)

Message: 91081   

 

hook up a debugger and step through it to see where it goes then

Attachments

    Outcomes