versioner: Add versioner_fortify_inline annotation
This commit adds versioner_fortify_inline annotation. This annotation
indicates that the annotated function is an overloaded inline function
for _FORTIFY_SOURCE implementation. They are usually enabled/disabled
by the enable_if attribute, thus the versioner don't have to check
whether they have conflicting definitions.
Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
source build/envsetup.sh && \
lunch aosp_arm64-userdebug && \
m versioner && \
./bionic/tools/versioner/run_tests.py
Change-Id: If5c739fc0c8a218907855939c1fe5338134da7f7
diff --git a/tools/versioner/tests/fortify_inline/headers/fcntl.h b/tools/versioner/tests/fortify_inline/headers/fcntl.h
new file mode 100644
index 0000000..dc81ef8
--- /dev/null
+++ b/tools/versioner/tests/fortify_inline/headers/fcntl.h
@@ -0,0 +1,29 @@
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+extern int open_real(const char* name, int flags, ...) __asm__("open");
+
+#define O_CREAT 00000100
+
+typedef unsigned int mode_t;
+
+static inline __attribute__((always_inline))
+int open(const char* name, int flags)
+ __attribute__((annotate("versioner_fortify_inline")))
+ __attribute__((overloadable))
+ __attribute__((enable_if(!(flags & O_CREAT), ""))) {
+ return open_real(name, flags);
+}
+
+static inline __attribute__((always_inline))
+int open(const char* name, int flags, mode_t mode)
+ __attribute__((annotate("versioner_fortify_inline")))
+ __attribute__((overloadable))
+ __attribute__((enable_if(flags & O_CREAT, ""))) {
+ return open_real(name, flags, mode);
+}
+
+#if defined(__cplusplus)
+}
+#endif
diff --git a/tools/versioner/tests/fortify_inline/platforms/libc.map.txt b/tools/versioner/tests/fortify_inline/platforms/libc.map.txt
new file mode 100644
index 0000000..2f09034
--- /dev/null
+++ b/tools/versioner/tests/fortify_inline/platforms/libc.map.txt
@@ -0,0 +1,4 @@
+LIBC {
+ global:
+ open;
+};
diff --git a/tools/versioner/tests/fortify_inline/run.sh b/tools/versioner/tests/fortify_inline/run.sh
new file mode 100644
index 0000000..9bfbe6d
--- /dev/null
+++ b/tools/versioner/tests/fortify_inline/run.sh
@@ -0,0 +1 @@
+versioner headers -p platforms -r arm -a 9 -a 12 -i
\ No newline at end of file