This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: rs6000.c tests TREE_ASM_WRITTEN too early.


On Fri, Dec 29, 2000 at 05:02:41AM -0000, Dave Korn wrote:
> 1)  Are you informing me here that if the shared lib contains
> 
> void foo(void) { ... }
> void bar(void) { ....; foo(); ... }
> 
> and there's a function foo() in the application that links with the lib,
> the call to foo() in bar() will be pointer by the linker at the foo() in
> the app, not the foo() in the lib?

Yes.  For SVR4 (and not AIX) semantics anyway.

> And is this in any way different from a weak declaration?

Well, yes and no.  See below.

> Should we just make a new predicate DECL_WEAK_OR_OVERRIDEABLE?

Maybe, but probably not.  How this would be used would be
entirely up to the target.

> Or should globally visible symbols in sysv4
> shared libraries be declared weak by default ?

No.

You have to understand how ELF dynamic symbol resolution works
to see the fine distinctions here.  

  (1) For each dynamic shared object (DSO) there is an ordered
      list of DSOs to check for symbols.  The rules for creating
      this list are somewhat complex, due to a multitude of 
      options that can be specified at DSO link time.  However,
      in general the application is first on the list.

  (2) When resolving a symbol for a DSO, we traverse the list
      of dependant DSOs and

      (a) If we find a strong definition, that is the symbol value.
      (b) If we find a weak definition, we remember it, but 
	  continue through the list looking for a strong
	  definition.  If no strong definition is found, we
	  take the first weak definition.

> 2)  Can I infer from your suggestion above that flag_pic is only ever set
> when building a shared library? IOW, it's not legitimate to use it just
> because you want code that can be stored in a flat .bin format without
> reloc info?

Certainly it's legitimate (ie possible) to use it for .bin stuff.
But that's really different semantics from what is required for
hosted ELF shared libraries.

Some ports have special flags to be used in non-hosted situations.
IA-64's -mconstant-gp and -mauto-pic are examples of these.  PowerPC
has -mrelocatable, but I'm not sure off the top of my head whether 
that implies some amount of PIC.


r~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]