Skip to content

Commit

Permalink
build: userspace: No merge globals
Browse files Browse the repository at this point in the history
Add a compiler option to not merge globals. gen_kobject_list.py
is not capable of distinguish addresses of merged objects. The script
itself does not look wrong. The dward specification says that the
attribute DW_AT_location with opcode DW_OP_addr encodes a machine
address and whose size is the size of an address on the target machine
but for merged objects the address is longer, not clear why.

Disable global merge when userspace is enabled to avoid this problem.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
  • Loading branch information
Flavio Ceolin authored and nashif committed Jan 26, 2023
1 parent 43781ba commit ac5d45a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ include(cmake/extra_flags.cmake)

zephyr_cc_option(-fno-asynchronous-unwind-tables)

if(CONFIG_USERSPACE)
zephyr_compile_options($<TARGET_PROPERTY:compiler,no_global_merge>)
endif()

if(CONFIG_THREAD_LOCAL_STORAGE)
# Only support local exec TLS model at this point.
zephyr_cc_option(-ftls-model=local-exec)
Expand Down
2 changes: 2 additions & 0 deletions cmake/compiler/arcmwdt/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ set_property(TARGET compiler-cpp PROPERTY no_threadsafe_statics "-fno-threadsafe
# but it has PIE disabled by default - so no extra flags are required here.
set_compiler_property(PROPERTY no_position_independent "")

set_compiler_property(PROPERTY no_global_merge "")

#################################
# This section covers asm flags #
#################################
Expand Down
2 changes: 2 additions & 0 deletions cmake/compiler/clang/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ set_compiler_property(PROPERTY warning_error_coding_guideline
-Wconversion
-Woverride-init
)

set_compiler_property(PROPERTY no_global_merge "-mno-global-merge")
5 changes: 5 additions & 0 deletions cmake/compiler/compiler_flags_template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ set_compiler_property(PROPERTY warning_no_pointer_arithmetic)

# Compiler flags for disabling position independent code / executable
set_compiler_property(PROPERTY no_position_independent)

# Compiler flag to avoid combine more than one global variable into a single aggregate.
# gen_kobject_list.py is does not understand it and end up identifying objects as if
# they had the same address.
set_compiler_property(PROPERTY no_global_merge)
2 changes: 2 additions & 0 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,5 @@ set_compiler_property(PROPERTY no_position_independent
-fno-pic
-fno-pie
)

set_compiler_property(PROPERTY no_global_merge "")

0 comments on commit ac5d45a

Please sign in to comment.