Skip to content

Commit

Permalink
Add empty .bss section enforcer in loader scripts for plugin compilation
Browse files Browse the repository at this point in the history
(cherry picked from commit 9988903)
  • Loading branch information
fbeutin-ledger authored and Xavier Chapron committed Aug 10, 2023
1 parent b54e134 commit 624de1e
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Makefile.rules_generic
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ $(OBJ_DIR)/%.o: %.S $(BUILD_DEPENDENCIES) prepare
$(L)$(call as_cmdline,$(INCLUDES_PATH), $(DEFINES),$<,$@)

ifeq ($(SCRIPT_LD),)
SCRIPT_LD:=$(BOLOS_SDK)/target/$(TARGET)/script.ld
LDFLAGS += -L$(BOLOS_SDK)/target/$(TARGET)
ifeq ($(IS_PLUGIN),)
SCRIPT_LD := $(BOLOS_SDK)/target/$(TARGET)/script.ld
else
SCRIPT_LD := $(BOLOS_SDK)/target/$(TARGET)/plugin_script.ld
$(info Using plugin link script: $(SCRIPT_LD))
endif
else
$(info Using custom link script: $(SCRIPT_LD))
endif
Expand Down
22 changes: 22 additions & 0 deletions target/fatstacks/plugin_script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/

/* Reuse the main linker script */
INCLUDE script.ld

/* No global variable allowed in plugins */
ASSERT( (_ebss - _bss) <= 0, ".bss section must be empty for plugins" )
4 changes: 2 additions & 2 deletions target/fatstacks/script.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Ledger Blue - Secure firmware
* (c) 2016, 2017, 2018, 2019 Ledger
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
22 changes: 22 additions & 0 deletions target/nanos/plugin_script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/

/* Reuse the main linker script */
INCLUDE script.ld

/* No global variable allowed in plugins */
ASSERT( (_ebss - _bss) <= 0, ".bss section must be empty for plugins" )
4 changes: 2 additions & 2 deletions target/nanos/script.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Ledger Blue - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020 Ledger
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
22 changes: 22 additions & 0 deletions target/nanos2/plugin_script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/

/* Reuse the main linker script */
INCLUDE script.ld

/* No global variable allowed in plugins */
ASSERT( (_ebss - _bss) <= 0, ".bss section must be empty for plugins" )
4 changes: 2 additions & 2 deletions target/nanos2/script.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Ledger Blue - Secure firmware
* (c) 2016, 2017, 2018, 2019 Ledger
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
22 changes: 22 additions & 0 deletions target/nanox/plugin_script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/

/* Reuse the main linker script */
INCLUDE script.ld

/* No global variable allowed in plugins */
ASSERT( (_ebss - _bss) <= 4, ".bss section must be empty for plugins" )
4 changes: 2 additions & 2 deletions target/nanox/script.ld
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Ledger Blue - Secure firmware
* (c) 2016, 2017, 2018, 2019 Ledger
* Ledger - Secure firmware
* (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Ledger
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 624de1e

Please sign in to comment.