Bug 30329 - Gcc Linker problem
Summary: Gcc Linker problem
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-29 07:01 UTC by shantibhushan
Modified: 2006-12-29 07:44 UTC (History)
1 user (show)

See Also:
Host: Linux
Target: Linux
Build: GCC
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shantibhushan 2006-12-29 07:01:47 UTC
If i have a shared lib with some name like FTPobex with funtion name

       Func1()
        {
           printf("First function");
         }

And i have my local function


     void main()
      {
         Func1();/i call this function here using shared lib
       }

//local function      
        Func1()
        {
           printf("First function");
         }

Here,Func1() is a local function for this program .My program is not giving any linker error on this when i compiled it using GCC.There are 2 definitions of same function then also it works..Amazaing...?
        Then i remove my local Func1() function then it goes to shaerd lib funciotn and access that...Quite strange ? TRy it.
           Hope GCC developers will look on it.
                           shantibhushan.sal2@gmail.com
Comment 1 Andrew Pinski 2006-12-29 07:44:39 UTC
This problem if it is a real issue, is not a GCC issue at all, GCC does not do dynamic loading or even the static linking.

The problem here is you don't understand elf semantics.  since we know that Func1 is local to the TU and you are not compiling with -fPIC/-fPIE/-fpie/-fpic, then we call directly Func1 in main instead of going through a PLT.