Ensure assert_fail and abort have noreturn attribute
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
uintptr_t __stack_chk_guard = 0xd048c37519fcadfe;
|
||||
|
||||
// manually define detailed abort function
|
||||
void __abort(const char *func, const char *file, int line);
|
||||
void __abort(const char *func, const char *file, int line) __attribute__((noreturn));
|
||||
|
||||
__attribute__((noreturn))
|
||||
void __stack_chk_fail(void) {
|
||||
|
||||
@@ -3,12 +3,3 @@ double strtod(const char *nptr, char **endptr);
|
||||
long double strtold(const char *nptr, char **endptr) {
|
||||
return (long double)strtod(nptr, endptr);
|
||||
}
|
||||
|
||||
// manually define detailed abort function
|
||||
void __abort(const char *func, const char *file, int line);
|
||||
|
||||
// backup definition of abort for programs that link it directly
|
||||
void abort(void) {
|
||||
// call detailed abort function
|
||||
__abort(__func__, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
@@ -7,3 +7,6 @@ cpp_compat = true
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
[fn]
|
||||
no_return = "__attribute__((noreturn))"
|
||||
|
||||
@@ -12,7 +12,7 @@ pub unsafe extern "C" fn __assert_fail(
|
||||
file: *const c_char,
|
||||
line: c_int,
|
||||
cond: *const c_char,
|
||||
) {
|
||||
) -> ! {
|
||||
let func = CStr::from_ptr(func).to_str().unwrap();
|
||||
let file = CStr::from_ptr(file).to_str().unwrap();
|
||||
let cond = CStr::from_ptr(cond).to_str().unwrap();
|
||||
|
||||
@@ -8,3 +8,6 @@ cpp_compat = true
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
[fn]
|
||||
no_return = "__attribute__((noreturn))"
|
||||
|
||||
@@ -89,12 +89,19 @@ pub unsafe extern "C" fn a64l(s: *const c_char) -> c_long {
|
||||
c_long::from(l)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn abort() -> ! {
|
||||
eprintln!("Legacy Abort");
|
||||
|
||||
intrinsics::abort();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn __abort(
|
||||
func: *const c_char,
|
||||
file: *const c_char,
|
||||
line: c_int,
|
||||
) {
|
||||
) -> ! {
|
||||
let func = CStr::from_ptr(func).to_str().unwrap();
|
||||
let file = CStr::from_ptr(file).to_str().unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user