I am using the GNU toolchain for an ARM project that I am working on. The project includes a real-time operating system (RTOS) and utilizes the memory protection unit (MPU) of the ARM Cortex-R4 CPU.
I am using a linker command (.ld
) file to map .bss
and .data
sections to blocks of memory that can made available to tasks that require access.
This particular application has several different build configurations. The project has two top-level source code folders, which for all intents and purposes I will call common
and custom
. Folder common
contains all of the source code used by all build configurations and folder custom
contains one subfolder for each build configuration containing the source code specific to that build configuration. For example, custom/build_cfg1
, custom/build_cfg2
, etc.
All of the custom
source code is called from a single RTOS task. I would like to set up the linker file to be able to place all .data
and .bss
sections from the custom
folder into a single section based on the file location, but the approach that I am using is not catching the .data
and .bss
sections. The following is an example of what the linker command file looks like:
.custom_bss (NOLOAD) : AT (0)
{
custom_bss_start = .;
"./custom/*" (.bss.*)
custom_bss_end = .;
}
/* Define initialized data separately since it must be loaded. */
.custom_data : AT(ld_custom_data_load_addr)
{
custom_data_start = .;
"./custom/*" (.data.*)
custom_data_end = .;
}
A few things to note:
./custom/
and that the .data
and .bss
sections are being mapped to catch-all .data
and .bss
sections.common
folder have already been mapped as needed..bss.*
and .data.*
, since I am using the -fdata-sections
option when compiling.Is there a technique for specifying the filename that will allow me to map all .bss
and .data
sections from a folder and its subfolders to a particular section using the linker command file?
After investigating further, I found that there was actually a problem with the way that I defined the input section (.bss) instead of (.bss.*). Once this was corrected, ./custom/*/*.o (.bss.*)
was able to pull in .bss sections from source files in subdirectories and subdirectories of subdirectories of custom
.