Reputation: 1
I am writing a cpm-like os for a Cortex-m microprocessor (Ti Tiva-C) using Ti CCS v12 IDE. It is a teaching/student project for junior students. The project will be divided in sub-project and assigned to students.
The project requires to allocate code at specific adresses/region of microcontroller memory, using a custom linker script.
However the linker largely ignores the code layout in the linker script and includes in the output code not requested in the linker script.
I removed the "(.text)" and "(.text.)" snippets that should include all the code and replaced with actual filenames of objects files "tpa_(.text)", divided into different output section.
It did not work, the code was moved around.
As a test, I completely removed all the reference to code in the linker script, but the linker still includes all the objects it founds in the command line.
Moving the location counter in the linker script moves the code in the output, hence the linker script is really read.
minimal linker script which reproduces the problem:
MEMORY
{
FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00040000
SRAM (WX) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}
REGION_ALIAS("REGION_TEXT", FLASH);
SECTIONS {
.text : {
. = 12k; /* just to check that this file is really read by linker */
/*KEEP (./bios/bios_startup_cpm_gcc.o(.intvecs)) */
} > REGION_TEXT
__data_start__ = .; /* to avoid unresolved external errors */
__data_load__ = .;
__data_end__ = .;
}
linker invocation
Building target: "test-linker.out"
Invoking: GNU Linker
"/Applications/ti/ccs1271/ccs/tools/compiler/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc-9.2.1" -mfpu=fpv4-sp-d16 -DPART_TM4C123GH6PM -Og -ffunction-sections -fdata-sections -g -gdwarf-3 -gstrict-dwarf -Wall -specs="nosys.specs" -march=armv7e-m -mthumb -mfloat-abi=soft -Wl,-Map,"test-linker.map" -nostartfiles -nodefaultlibs -nostdlib -static -o"test-linker.out" "./tpa/libbios.o" "./tpa/tpa_test.o" "./bios/bios_startup_cpm_gcc.o" "./bios/bios_util.o" "./bios/fixed_dispatch.o" -Wl,-T"../cpm.lds" "./bios/bios_test.o"
Finished building target: "test-linker.out"
output linker map
Memory Configuration
Name Origin Length Attributes
FLASH 0x0000000000000000 0x0000000000040000 xr
SRAM 0x0000000020000000 0x0000000000008000 xw
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
LOAD ./tpa/libbios.o
LOAD ./tpa/tpa_test.o
LOAD ./bios/bios_startup_cpm_gcc.o
LOAD ./bios/bios_util.o
LOAD ./bios/fixed_dispatch.o
.text 0x0000000000000000 0x3024
0x0000000000003000 . = 0x3000
*fill* 0x0000000000000000 0x3000
.text 0x0000000000003000 0x20 ./tpa/libbios.o
0x0000000000003000 call_const
0x0000000000003006 call_conin
0x000000000000300c call_conout
.text 0x0000000000003020 0x0 ./tpa/tpa_test.o
.text 0x0000000000003020 0x0 ./bios/bios_startup_cpm_gcc.o
.text 0x0000000000003020 0x4 ./bios/bios_util.o
0x0000000000003020 noop
.text 0x0000000000003024 0x0 ./bios/fixed_dispatch.o
.text 0x0000000000003024 0x0 ./bios/bios_test.o
0x0000000000003024 __data_start__ = .
0x0000000000003024 __data_load__ = .
0x0000000000003024 __data_end__ = .
LOAD ./bios/bios_test.o
OUTPUT(test-linker.out elf32-littlearm)
.data 0x0000000000003024 0x0
.data 0x0000000000003024 0x0 ./tpa/libbios.o
.data 0x0000000000003024 0x0 ./tpa/tpa_test.o
.data 0x0000000000003024 0x0 ./bios/bios_startup_cpm_gcc.o
.data 0x0000000000003024 0x0 ./bios/bios_util.o
.data 0x0000000000003024 0x0 ./bios/fixed_dispatch.o
.data 0x0000000000003024 0x0 ./bios/bios_test.o
.igot.plt 0x0000000000003024 0x0
.igot.plt 0x0000000000003024 0x0 ./tpa/libbios.o
.glue_7 0x0000000000003024 0x0
.glue_7 0x0000000000003024 0x0 linker stubs
.glue_7t 0x0000000000003024 0x0
.glue_7t 0x0000000000003024 0x0 linker stubs
.vfp11_veneer 0x0000000000003024 0x0
.vfp11_veneer 0x0000000000003024 0x0 linker stubs
.v4_bx 0x0000000000003024 0x0
.v4_bx 0x0000000000003024 0x0 linker stubs
.iplt 0x0000000000003024 0x0
.iplt 0x0000000000003024 0x0 ./tpa/libbios.o
.text.tpa_start
0x0000000000003024 0x18
.text.tpa_start
0x0000000000003024 0x18 ./tpa/tpa_test.o
0x0000000000003024 tpa_start
.text.NmiSR 0x000000000000303c 0x2
.text.NmiSR 0x000000000000303c 0x2 ./bios/bios_startup_cpm_gcc.o
.text.IntDefaultHandler
0x000000000000303e 0x2
.text.IntDefaultHandler
0x000000000000303e 0x2 ./bios/bios_startup_cpm_gcc.o
.text.FaultISR 0x0000000000003040 0x8
.text.FaultISR
0x0000000000003040 0x8 ./bios/bios_startup_cpm_gcc.o
.text.ResetISR 0x0000000000003048 0x3c
.text.ResetISR
0x0000000000003048 0x3c ./bios/bios_startup_cpm_gcc.o
0x0000000000003048 ResetISR
.text.bios_dispatch
0x0000000000003084 0xa
.text.bios_dispatch
0x0000000000003084 0xa ./bios/fixed_dispatch.o
0x0000000000003084 bios_dispatch
.text.main 0x000000000000308e 0xa
.text.main 0x000000000000308e 0xa ./bios/bios_test.o
0x000000000000308e main
.intvecs 0x0000000000003098 0x26c
.intvecs 0x0000000000003098 0x26c ./bios/bios_startup_cpm_gcc.o
0x0000000000003098 g_pfnVectors
.rel.dyn 0x0000000000003304 0x0
.rel.iplt 0x0000000000003304 0x0 ./tpa/libbios.o
.bss 0x0000000000003304 0x0
.bss 0x0000000000003304 0x0 ./tpa/libbios.o
.bss 0x0000000000003304 0x0 ./tpa/tpa_test.o
.bss 0x0000000000003304 0x0 ./bios/bios_startup_cpm_gcc.o
.bss 0x0000000000003304 0x0 ./bios/bios_util.o
.bss 0x0000000000003304 0x0 ./bios/fixed_dispatch.o
.bss 0x0000000000003304 0x0 ./bios/bios_test.o
For some reason the linker includes all the code in the command line disregarding the requests in the linke script.
Upvotes: 0
Views: 40