LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-21-2006, 09:34 AM   #1
RPDP
LQ Newbie
 
Registered: Sep 2006
Posts: 8

Rep: Reputation: 0
gnu arm issue in linking "__inline" methods


Hi all,

I am working in BREW and configured GNU ARM toolchain for compiling.

I used GNU ARM to compile my sources (.c files) which compiled fine, but when calling "arm-elf-ld" for linking the .o files, it complains about mulitple definitions of the included routines.

utils.o(.text+0x2a8): In function `ISOCKET_GetSockName':
: multiple definition of `ISOCKET_GetSockName'
paint.o(.text+0x2c10): first defined here
utils.o(.text+0x2fc): In function `ISOCKET_SetOpt':
: multiple definition of `ISOCKET_SetOpt'
paint.o(.text+0x2c64): first defined here
utils.o(.text+0x34c): In function `ISOCKET_GetOpt':
: multiple definition of `ISOCKET_GetOpt'
.....
make: *** [sudoku.elf] Error 1


All the above methods are caused by __inline methods defined in one of the BREW SDK file - AEENet.h.

I went thru many forums and came to a rough conclusion that GCC linking has problems in linking __inline methods. Most of the time they suggest to change "__inline" to "extern __inline" or "static __inline".

If I change like said above, the linking works perfectly. But I feel changing an SDK file is not recommended and also the same source compiles and links fine with ARM Dev Suite without changing.

Is this a gcc linker bug?
Is there any option in GNU compiling or linking to avoid this error.
[one option is add --allow-mulitple-definition flag, but that bloats up the code - so rejected]

Any help is very much appreciated.

Thanks in Advance,
R.Pradeep
 
Old 09-24-2006, 01:23 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
The problem is not in gcc itself, but in a different definitions of __inline (as it's simply #defined). It maybe possible to fix the issue by undefining __inline at the beginning of certain files, but it depends how it is defined in different files. For example, how do the prototype of the functions causing errors look like in all files they're used?
 
Old 09-25-2006, 04:10 AM   #3
RPDP
LQ Newbie
 
Registered: Sep 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thumbs down

Hi Mara.

Thanks for the reply.

I changed the AEENet.h (SDK header)file with "static __inline" (or) "extern __inline" (or) "#define". And then compiled the .dll for emulator. The app launches fine but when a network request is made, the emulator crashes.
So changes in the SDK header does not seems to be the right option in this case.

The same sources work fine with Visual Studio and also in ARM Dev. Suite compilers without any changes.
So I am little confused with using GCC linking options
Any idea why this happens in GCC alone?

Thanks,
R.Pradeep
 
Old 09-25-2006, 03:17 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
With wrong __incline definition it should simply produce compile errors, not crash (excluding a case when there are two different functions with only return argument different and using __inline, which is unlikely). My guess is that the crash is unrelated. BTW which one crashes, emulator or program inside emulator?
 
Old 09-26-2006, 01:41 AM   #5
RPDP
LQ Newbie
 
Registered: Sep 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
With wrong __incline definition it should simply produce compile errors, not crash
Yes the compiler does produce error as I mentioned in the first post.
The crash occurs only when I change "__inline" to "static __inline" (or) "extern __inline" (or) "#define" in the SDK header containing the __inline methods.
This was suggested in certain forums to solve the linking errors posted in the first post.

Quote:
(excluding a case when there are two different functions with only return argument different and using __inline, which is unlikely).
Do you mean "two different functions with the same name" ?.
If so, then this is not the case, as the __inline methods are in the SDK header file. Which does compile and link without any errors in visual studio.

Quote:
My guess is that the crash is unrelated.
to be a linking problem with GCC, as the same sources works fine when used with visual studio and ARM dev. suite compilers.

Quote:
BTW which one crashes, emulator or program inside emulator?
The emulator crashes, when the application makes a network call.
 
Old 09-26-2006, 03:13 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
Originally Posted by RPDP
Yes the compiler does produce error as I mentioned in the first post.
The crash occurs only when I change "__inline" to "static __inline" (or) "extern __inline" (or) "#define" in the SDK header containing the __inline methods.
I'm wondering how is __inline defined. Have you tried searching the SDK and your GCC environment (I think it's simply 'inline' for gcc). I'd try with __inline beeing simply 'inline', with no more modifiers. Another try - redefine __inline as empty, eg.
#define __inline

Quote:
Do you mean "two different functions with the same name" ?.
I meant your source having two functions, one is __inline somefun and another, for example static inline somefun. The result is diferent depending on the definiton of __inline.

Quote:
The emulator crashes, when the application makes a network call.
I think it's unreated to the __inline thing. Not initialized pointer etc (compilers use different default values, so such bug may not be noticed when using one compiler while crashing happily when using another).
 
Old 09-27-2006, 06:22 AM   #7
RPDP
LQ Newbie
 
Registered: Sep 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
I'm wondering how is __inline defined. Have you tried searching the SDK and your GCC environment (I think it's simply 'inline' for gcc).
The SDK header contains methods like below:

// pseudo-methods
__inline int ISOCKET_Realize(ISocket *me)
{
return ISOCKET_IOCtl(me, ISOCKET_IOCTL_REALIZE, 0);
}
__inline int ISOCKET_Listen(ISocket *me, int nBacklog)
{
return ISOCKET_IOCtl(me, ISOCKET_IOCTL_LISTEN, (uint32)nBacklog);
}
......


I tried as you mentioned but the same error occurs and also gcc.info document mentions

(If you are writing a header file to be included in ISO C programs,
write `__inline__' instead of `inline'. *Note Alternate Keywords::.)

so for C, I think it should not be just "inline"

Quote:
I think it's unreated to the __inline thing. Not initialized pointer etc (compilers use different default values, so such bug may not be noticed when using one compiler while crashing happily when using another).
For this I had the same doubt as you said, and I checked out my sources for unintialised variables, pointers, etc., but none of them is directly related or used in the network request part of the code where the program seems to crash.
 
Old 09-27-2006, 04:14 PM   #8
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
Originally Posted by RPDP
The SDK header contains methods like below:
With the code you have provided, both static inline and inline cause no harm. It's only about code size in this case.

Quote:
I tried as you mentioned but the same error occurs and also gcc.info document mentions
Which version? One of the possible redefines should make it compile.
Quote:

(If you are writing a header file to be included in ISO C programs,
write `__inline__' instead of `inline'. *Note Alternate Keywords::.)

so for C, I think it should not be just "inline"
It says about __inline__, not __inline. Which is often used, BTW.

Quote:
For this I had the same doubt as you said, and I checked out my sources for unintialised variables, pointers, etc., but none of them is directly related or used in the network request
part of the code where the program seems to crash.
Do you have any chance to see if it crashes near the functions that have problems with inline? You have an emulator, so finding the crash point should be easy.
 
Old 09-28-2006, 06:21 AM   #9
RPDP
LQ Newbie
 
Registered: Sep 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Hi Mara,

I felt the same, changing it to static or to a #define does not affect the code. But it seems to crash when it is run in the emulator.

I use gcc 3.3.1 which come along with GNUDE, I also tried WinARM, which has a recent version gcc 4.1.1. Both throws out the same error while linking.


Quote:
Do you have any chance to see if it crashes near the functions that have problems with inline? You have an emulator, so finding the crash point should be easy.
I did try getting the emulator output from the output window, but when the emulator crashes it takes out the output window with it. So from the visual clues [the application screen], the crash happens just after the network request is made.

My main confusion is why is GCC not able to compile and link "__inline" methods properly? Why is it needed to define it as static inline or #define to solve this problem for GCC alone?
 
Old 09-29-2006, 04:07 PM   #10
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
Originally Posted by RPDP
I did try getting the emulator output from the output window, but when the emulator crashes it takes out the output window with it. So from the visual clues [the application screen], the crash happens just after the network request is made.
My standard technique in such case is to insert printfs and sleep calls at the places I suspect. Sleeps must be long enough so I can notice what was the last message. It's not an effective method, but works for extreme cases

Quote:
My main confusion is why is GCC not able to compile and link "__inline" methods properly? Why is it needed to define it as static inline or #define to solve this problem for GCC alone?
For gcc, "__inline" is equal to "my_own_modifier". it must be defined somewhere. In your case it seems to be defined twice and, what's not very good, differently.
 
Old 09-30-2006, 07:11 AM   #11
RPDP
LQ Newbie
 
Registered: Sep 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Hi Mara,

Seems I have to go with VC and ARM ADS compilers for now, as I feel any changes to the SDK headers can cause problems in the device and also the app needs to be pass the True BREW Testing which has a cost associated with it.
Also BREW does not officially support GNU ARM.
Hope BREW support people will provide an updated header for this issue soon.

Thanks Mara for help and support extended.

Thanks,
R.Pradeep
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linking problem: "multiple definition of .." qanopus Programming 11 05-03-2012 03:04 AM
SSH issue ""Server unexpectedly closed network connection" Errsta_Fonzarelli Linux - Software 12 05-24-2010 02:35 PM
running "hello world" in ARM Integrator Board ayeong Linux - Newbie 4 09-12-2006 02:01 AM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 09:40 AM
localhost:901 gets redirected to "Power Linking" web site advertisement condosolon Linux - Newbie 2 03-04-2004 12:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration