Bug 18646 - function pointer values are still interposed with -Bsymbolic-functions on ARM
Summary: function pointer values are still interposed with -Bsymbolic-functions on ARM
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-09 00:54 UTC by Michael Hudson-Doyle
Modified: 2015-09-09 13:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
fix ported from aarch64 (283 bytes, patch)
2015-07-09 00:54 UTC, Michael Hudson-Doyle
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Hudson-Doyle 2015-07-09 00:54:16 UTC
Created attachment 8422 [details]
fix ported from aarch64

If this code is in a shared library, linked with -Bsymbolic-functions ld.bfd on arm (32):

#include <stdio.h>
#include "dep.h"

int interpos(void) {
	return 0;
}

intfunc intfuncs[] = { interpos };

intfunc
getintfunc(void) {
	return intfuncs[0];
}

void
callinterpos(void) {
	printf("calling interpos directly says %d\n", interpos());
}


and this code is in a linked executable:

#include <stdio.h>
#include "dep/dep.h"

int interpos() {
	return 1;
}

int main(int argc, char** argv) {
	callinterpos();
	printf("calling interpos via pointer says %d\n", getintfunc()());
}

then running the executable prints

calling interpos directly says 0
calling interpos via pointer says 1

when it should print 0 twice.  Luckily for me, the isomorphic bug got fixed for aarch64 recently in https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=0941db698eba22727c9a944b5da5c76ae93cc664 and the same fix (attached) fixes the problem for ARM too.
Comment 1 Nick Clifton 2015-09-09 13:39:07 UTC
Hi Michael,

  Thanks for reporting this problem.  Fortunately it has already been fixed:

    2015-07-25  Thomas Preud'homme  <thomas.preudhomme@arm.com>

	* elf32-arm.c (elf32_arm_final_link_relocate): Use SYMBOLIC_BIND to
	check if a symbol should be bound symbolically.

Cheers
  Nick