aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2021-01-27 13:22:26 +0000
committerGravatar GitHub <noreply@github.com> 2021-01-27 13:22:26 +0000
commit7b27817237cf22d1b92f3638d546dacf60d2a97d (patch)
tree8aa463a93a2f9a2a8e07cd97278ed6df85f5fb96 /cortex-m-rt
parent8a64815108bf266e97a82c9be89bbc2ccbf0a5c3 (diff)
parentf0e2218330adcffe7dc8a05869dac0e5399058c3 (diff)
downloadcortex-m-7b27817237cf22d1b92f3638d546dacf60d2a97d.tar.gz
cortex-m-7b27817237cf22d1b92f3638d546dacf60d2a97d.tar.zst
cortex-m-7b27817237cf22d1b92f3638d546dacf60d2a97d.zip
Merge #310
310: Only emit link_section for cortex-m r=jonas-schievink a=adamgreig Previously we always emitted `link_section`, even though it only had an effect when our linker script was being used (and only made sense on cortex-m targets). This breaks building the code for a MacOS target, which is occasionally useful for running `cargo check` etc. In the macros crate we don't have the target information available, so instead we continue to emit `link_section` except specifically on MacOS. This keeps the fix from #306 but hopefully resolves the confusion in https://github.com/rust-embedded/cortex-m-rt/issues/74#issuecomment-768079657. Co-authored-by: Adam Greig <adam@adamgreig.com>
Diffstat (limited to 'cortex-m-rt')
-rw-r--r--cortex-m-rt/macros/src/lib.rs6
-rw-r--r--cortex-m-rt/src/lib.rs12
2 files changed, 8 insertions, 10 deletions
diff --git a/cortex-m-rt/macros/src/lib.rs b/cortex-m-rt/macros/src/lib.rs
index 74041ef..fe0264f 100644
--- a/cortex-m-rt/macros/src/lib.rs
+++ b/cortex-m-rt/macros/src/lib.rs
@@ -278,8 +278,10 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
#(#attrs)*
#[doc(hidden)]
#[export_name = "HardFault"]
- #[cfg_attr(target_os = "macos", link_section = ".HardFault,user")]
- #[cfg_attr(not(target_os = "macos"), link_section = ".HardFault.user")]
+ // Only emit link_section when building for embedded targets,
+ // because some hosted platforms (used to check the build)
+ // cannot handle the long link section names.
+ #[cfg_attr(target_os = "none", link_section = ".HardFault.user")]
pub unsafe extern "C" fn #tramp_ident(frame: &::cortex_m_rt::ExceptionFrame) {
#ident(frame)
}
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index 93125b7..cb1b5f7 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -910,15 +910,13 @@ pub fn heap_start() -> *mut u32 {
// Entry point is Reset.
#[doc(hidden)]
-#[cfg_attr(target_os = "macos", link_section = ".vector_table,reset_vector")]
-#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.reset_vector")]
+#[cfg_attr(cortex_m, link_section = ".vector_table.reset_vector")]
#[no_mangle]
pub static __RESET_VECTOR: unsafe extern "C" fn() -> ! = Reset;
#[allow(unused_variables)]
#[doc(hidden)]
-#[cfg_attr(target_os = "macos", link_section = ".HardFault,default")]
-#[cfg_attr(not(target_os = "macos"), link_section = ".HardFault.default")]
+#[cfg_attr(cortex_m, link_section = ".HardFault.default")]
#[no_mangle]
pub unsafe extern "C" fn HardFault_(ef: &ExceptionFrame) -> ! {
loop {
@@ -1010,8 +1008,7 @@ pub union Vector {
}
#[doc(hidden)]
-#[cfg_attr(target_os = "macos", link_section = ".vector_table,exceptions")]
-#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.exceptions")]
+#[cfg_attr(cortex_m, link_section = ".vector_table.exceptions")]
#[no_mangle]
pub static __EXCEPTIONS: [Vector; 14] = [
// Exception 2: Non Maskable Interrupt.
@@ -1073,8 +1070,7 @@ pub static __EXCEPTIONS: [Vector; 14] = [
// to the default handler
#[cfg(all(any(not(feature = "device"), test), not(armv6m)))]
#[doc(hidden)]
-#[cfg_attr(target_os = "macos", link_section = ".vector_table,interrupts")]
-#[cfg_attr(not(target_os = "macos"), link_section = ".vector_table.interrupts")]
+#[cfg_attr(cortex_m, link_section = ".vector_table.interrupts")]
#[no_mangle]
pub static __INTERRUPTS: [unsafe extern "C" fn(); 240] = [{
extern "C" {