-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[BOLT] Always treat function entry as code #160161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-bolt Author: Maksim Panchenko (maksfb) ChangesIf an address has both, a data marker "$d" and a function entry point associated with it, treat it as code. Full diff: https://github.com/llvm/llvm-project/pull/160161.diff 2 Files Affected:
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index a6e4dbc9c192f..014fa43f82867 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -917,9 +917,6 @@ void RewriteInstance::discoverFileObjects() {
bool IsData = false;
uint64_t LastAddr = 0;
for (const auto &SymInfo : SortedSymbols) {
- if (LastAddr == SymInfo.Address) // don't repeat markers
- continue;
-
MarkerSymType MarkerType = BC->getMarkerType(SymInfo.Symbol);
// Treat ST_Function as code.
diff --git a/bolt/test/AArch64/function-data-marker.s b/bolt/test/AArch64/function-data-marker.s
new file mode 100644
index 0000000000000..35e31e9fc1731
--- /dev/null
+++ b/bolt/test/AArch64/function-data-marker.s
@@ -0,0 +1,25 @@
+## TODO
+
+# RUN: %clang %cflags %s -o %t.exe -nostdlib -fuse-ld=lld -Wl,-q
+# RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg --print-only=foo 2>&1 | FileCheck %s
+
+# BOLT-WARNING: function symbol foo lacks code marker
+
+.text
+.balign 4
+
+.global _start
+.type _start, %function
+_start:
+ bl foo
+ ret
+.size _start, .-_start
+
+## Data marker is emitted immediately before the function.
+.global foo
+.type foo, %function
+$d:
+foo:
+ ret
+.size foo, .-foo
+
|
For the test, maybe we can also add a case where |
@maksfb as workaround we can try the following
|
@yavtuk do you have an example where we have data at the start of the function? I'd like to consider us treating such cases differently, i.e. shift the function entry point to an actual code location. |
Now I found only couple commits which can be related to this
also you can take a look at this commit I'll add more specific details if I find them |
@maksfb I can't find the exactly function but for x86 I remember we faced with function smth like that
entry point for the one was with 256 offset, in openssl it was a data which is used for algorithm I think we can re-check openssl 3.x and 1.1.x versions and take a look is this still exist |
This one makes sense. Even though it's better be using |
Thanks. I'll take a look at the library. |
@yavtuk Have you seen the following commit to openssl? It basically duplicates your change, but for a different reasons: |
I think we can ignore x86 in the context of constant islands, since we don't create them for x86. For aarch64, I checked openssl 1.1.1 and 3.x. Only in
Of those four, only To summarize, it seems to be safe to resolve a conflict between |
ec10c71
to
e0f7725
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
If an address has both, a data marker "$d" and a function symbol associated with it, treat it as code.
e0f7725
to
2252da8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for investigating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an address has both, a data marker "$d" and a function symbol associated with it, treat it as code.