-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BOLT] Fix LSDA section handling #71821
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SECTIONS { | ||
.text : { *(.text*) } | ||
.gcc_except_table.main : { *(.gcc_except_table*) } | ||
. = 0x20000; | ||
.eh_frame : { *(.eh_frame) } | ||
. = 0x80000; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// This test check that LSDA section named by .gcc_except_table.main is | ||
// disassembled by BOLT. | ||
|
||
// RUN: %clang++ %cxxflags -O3 -flto=thin -no-pie -c %s -o %t.o | ||
// RUN: %clang++ %cxxflags -flto=thin -no-pie -fuse-ld=lld %t.o -o %t.exe \ | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is ThinLTO flag needed for this test case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently definitely not since I've added @rafaelauler offer to the ld script at least (I'm not sure does the problem has any connection to lto by default, probably not). I've just re-used the test provided in #71804 . Does it raise some problem here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve had an issue on a system where lld’s version didn’t match that of the compiler. Uncommon scenario, but nevertheless it’s better to fix. |
||
// RUN: -Wl,-q -Wl,--script=%S/Inputs/lsda.ldscript | ||
// RUN: llvm-readelf -SW %t.exe | FileCheck %s | ||
// RUN: llvm-bolt %t.exe -o %t.bolt | ||
|
||
// CHECK: .gcc_except_table.main | ||
|
||
#include <iostream> | ||
|
||
class MyException : public std::exception { | ||
public: | ||
const char *what() const throw() { | ||
return "Custom Exception: an error occurred!"; | ||
} | ||
}; | ||
|
||
int divide(int a, int b) { | ||
if (b == 0) { | ||
throw MyException(); | ||
} | ||
return a / b; | ||
} | ||
|
||
int main() { | ||
try { | ||
int result = divide(10, 2); // normal case | ||
std::cout << "Result: " << result << std::endl; | ||
result = divide(5, 0); // will cause exception | ||
std::cout << "Result: " << result << std::endl; | ||
// this line will not execute | ||
} catch (const MyException &e) { | ||
// catch custom exception | ||
std::cerr << "Caught exception: " << e.what() << std::endl; | ||
} catch (const std::exception &e) { | ||
// catch other C++ exceptions | ||
std::cerr << "Caught exception: " << e.what() << std::endl; | ||
} catch (...) { | ||
// catch all other exceptions | ||
std::cerr << "Caught unknown exception" << std::endl; | ||
} | ||
|
||
return 0; | ||
} |
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.
lld creates a PF_R PT_LOAD. For best portability, the first section of each segment should be specified. I created #93763