http://sourceware.org/bugzilla/show_bug.cgi?id=13302

             Bug #: 13302
           Summary: IRELATIVE relocation should come last
           Product: binutils
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


Assume this code:

extern int f(void);

void alt1(void) { }
void alt2(void) { }

static void (*resolve (void)) (void)
{
  return f() ? alt1 : alt2;
}

void fct(void) __attribute__ ((ifunc ("resolve")));
extern __typeof(fct) int_fct __attribute__ ((alias("fct")));

void g(void) {
  int_fct();
}



And this linker map:

{
  global:
  fct;
  local:
  *;
};



Compiling using

  gcc -shared -fpic  bug.c -Wl,--version-script,bug.map


The problem is the .rela.plt / .rel.plt section.  On my x86-64 system it looks
like this:

  0x0000000000200858  X86_64_JUMP_SLOT 000000000000000000      +0
__cxa_finalize
  0x0000000000200860  X86_64_IRELATIVE 000000000000000000   +1304 
  0x0000000000200868  X86_64_JUMP_SLOT 000000000000000000      +0 f



This is a problem, the ifunc for the IRELATIVE relocation calls f.  That PLT
slot isn't set up yet.


There is no problem with an ifunc callback to call another function.  Therefore
IRELATIVE relocation should all be moved to the back of the section.  There are
no drawbacks to doing this and carefully designed DSOs can call functions in
ifunc callbacks.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to