Skip to content

Commit

Permalink
Merge pull request #372 from LedgerHQ/fbe/load_script_improvements
Browse files Browse the repository at this point in the history
Fbe/load script improvements
  • Loading branch information
fbeutin-ledger authored Aug 9, 2023
2 parents 5f4ab50 + 9988903 commit b82507e
Show file tree
Hide file tree
Showing 9 changed files with 109 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/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" )
6 changes: 4 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 Expand Up @@ -94,6 +94,8 @@ SECTIONS

} > DISCARD /*> SRAM AT>FLASH = 0x00 */

ASSERT( (_edata - _data) <= 0, ".data section must be empty" )

.bss :
{
/**
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" )
6 changes: 4 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 Expand Up @@ -96,6 +96,8 @@ SECTIONS

} > DISCARD /*> SRAM AT>FLASH = 0x00 */

ASSERT( (_edata - _data) <= 0, ".data section must be empty" )

/* The .init_array is initialized with functions with the constructor
* attribute. Discard this section since there's no loader. */
/DISCARD/ : {
Expand Down
22 changes: 22 additions & 0 deletions target/stax/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" )
6 changes: 4 additions & 2 deletions target/stax/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 Expand Up @@ -95,6 +95,8 @@ SECTIONS

} > DISCARD /*> SRAM AT>FLASH = 0x00 */

ASSERT( (_edata - _data) <= 0, ".data section must be empty" )

.bss :
{
/**
Expand Down

0 comments on commit b82507e

Please sign in to comment.