* -Bsymbolic-functions breaks PMF comparison under ARM
@ 2014-01-09 23:46 Giuseppe D'Angelo
0 siblings, 0 replies; only message in thread
From: Giuseppe D'Angelo @ 2014-01-09 23:46 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1.1: Type: text/plain, Size: 1091 bytes --]
Hello,
the attached program changes the output from "true" to "false" when the
-Bsymbolic / -Bsymbolic-functions options are passed to GCC. This
happens on ARM -- on x86-64 output is always "true".
The program involves a comparison, within a shared library, of a PMF
defined inside the shared library itself with the same PMF passed by the
application.
At this stage I still don't know if it's a GCC problem, a ld.so problem,
ABI constraints, undefined behaviour, or whatnot; but any help is
appreciated.
Compile with:
> g++ -fPIC -shared -Wall -o libshared.so -Wl,-Bsymbolic shared.cpp
> g++ -fPIE -Wall -o main main.cpp -L. -lshared
(The long story is that Qt 5 is taking PMFs in its public API, and the
comparison failing inside of Qt shared libraries is breaking code on
ARM, as -Bsymbolic is set by default there.)
Thanks,
--
Giuseppe D'Angelo | giuseppe.dangelo@kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: main.cpp --]
[-- Type: text/x-c++src; name="main.cpp", Size: 278 bytes --]
#include <iostream>
#include "shared.h"
struct T : S
{
T() {
foo();
}
};
bool magic(Spmf f) { return test(reinterpret_cast<void **>(&f)); }
int main()
{
using namespace std;
T t;
cout << boolalpha << magic(&T::foo) << endl;
}
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: shared.cpp --]
[-- Type: text/x-c++src; name="shared.cpp", Size: 425 bytes --]
#include "shared.h"
#include <cstring>
S::~S() {}
void S::foo() {}
void S::bar() {}
static const Spmf spmfArray[] = { 0, &S::foo, 0 };
static const size_t spmfArraySize = sizeof(spmfArray) / sizeof(spmfArray[0]);
bool test(void **f)
{
for (size_t i = 0; i < spmfArraySize; ++i) {
if (spmfArray[i] == *reinterpret_cast<Spmf *>(f))
return true;
}
return false;
}
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: shared.h --]
[-- Type: text/x-chdr; name="shared.h", Size: 187 bytes --]
#ifndef SHARED_H
#define SHARED_H
struct S {
virtual ~S();
void foo();
void bar();
};
typedef void (S::*Spmf)();
bool test(void **f);
#endif // SHARED_H
[-- Attachment #2: Firma crittografica S/MIME --]
[-- Type: application/pkcs7-signature, Size: 4048 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-01-09 23:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-09 23:46 -Bsymbolic-functions breaks PMF comparison under ARM Giuseppe D'Angelo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).