Run constructors before resolving ifunc functions
Bug: 17177284
(cherry picked from commit 9598b8c415)
Change-Id: I2c9631ee1cd77f8cf95ec0216a35b605c8786454
This commit is contained in:
@@ -17,7 +17,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int g_flag = 0;
|
||||
|
||||
static void __attribute__((constructor)) init_flag() {
|
||||
g_flag = 1;
|
||||
}
|
||||
|
||||
const char* foo() __attribute__ ((ifunc ("foo_ifunc")));
|
||||
const char* is_ctor_called() __attribute__ ((ifunc("is_ctor_called_ifun")));
|
||||
|
||||
const char* return_true() {
|
||||
return "true";
|
||||
}
|
||||
|
||||
const char* return_false() {
|
||||
return "false";
|
||||
}
|
||||
|
||||
const char* f1() {
|
||||
return "unset";
|
||||
@@ -27,6 +42,10 @@ const char* f2() {
|
||||
return "set";
|
||||
}
|
||||
|
||||
void* is_ctor_called_ifun() {
|
||||
return g_flag == 0 ? return_false : return_true;
|
||||
}
|
||||
|
||||
void* foo_ifunc() {
|
||||
char* choice = getenv("IFUNC_CHOICE");
|
||||
return choice == NULL ? f1 : f2;
|
||||
@@ -34,4 +53,4 @@ void* foo_ifunc() {
|
||||
|
||||
const char* foo_library() {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user