esp-idf/tools/ldgen
Tian Yunhao b246ec86f3 ldgen: override LC_ALL to C before running objdump
When using a Linux system configured with `zh_CN.UTF-8` as `$LANG`,
and running raw cmake command to build the project (rather than using
`idf.py build`), output of objdump will be Chinese
(like `在归档文件 libesp_pm.a 中`), resulting in parsing error
`pyparsing.ParseException: Expected "In archive" (at char 0), (line:1, col:1)`
at entity.py line 129.

This commit forces objdump to use raw locale setting (`C`), to ensure
it always make English output that's able to be parsed.

Closes https://github.com/espressif/esp-idf/pull/7903
2021-11-15 17:55:24 +01:00
..
samples Build & config: Remove the "make" build system 2021-11-10 09:53:53 +01:00
test ldgen: generate ld files with fixed order of entries 2021-10-26 10:43:15 +08:00
__init__.py tools: implement linker script generation 2018-11-16 12:42:02 +08:00
entity.py ldgen: additional documentations re. internal workings 2021-03-09 14:42:38 +08:00
fragments.py ldgen: additional documentations re. internal workings 2021-03-09 14:42:38 +08:00
generation.py ldgen: generate ld files with fixed order of entries 2021-10-26 10:43:15 +08:00
ldgen_common.py ldgen: refactor generation tests and description addition 2021-02-05 10:20:37 +08:00
ldgen.py ldgen: override LC_ALL to C before running objdump 2021-11-15 17:55:24 +01:00
linker_script.py ldgen: generate ld files with fixed order of entries 2021-10-26 10:43:15 +08:00
output_commands.py ldgen: additional documentations re. internal workings 2021-03-09 14:42:38 +08:00
README.md ldgen: additional documentations re. internal workings 2021-03-09 14:42:38 +08:00
sdkconfig.py ldgen: additional documentations re. internal workings 2021-03-09 14:42:38 +08:00

Linker Script Generator

Contains code that implements linker script generation, ldgen. For more information about the feature, see docs/en/api-guides/linker-script-generation.rst.

Source Files

The following are the source files in the directory:

  • ldgen.py - Python executable that gets called during build.
  • entity.py - contains classes related to entities (library, object, symbol or combination of the above) with mappable input sections.
  • fragments.py - contains classes for parsing the different types of fragments in linker fragment files.
  • generation.py - contains bulk of the logic used to process fragments into output commands.
  • sdkconfig.py - used for evaluating conditionals in fragment files.
  • linker_script.py - augments the input linker script template with output commands from generation process to produce the output linker script.
  • output_commands.py - contains classes that represent the output commands in the output linker script.
  • ldgen_common.py - contains miscellaneous utilities/definitions that can be used in the files mentioned above.

Tests

Unit tests are in the test directory. These tests are run as part of CI in the job test_ldgen_on_host.

There is also a test app for ldgen in tools/test_apps/build_system/ldgen_test.

Build System

Linker script generation is a part of the build process. The build scripts tools/cmake/ldgen.cmake and make/ldgen.mk contain the build-system-side implementation for CMake and Make, respectively.

Basic Flow

The build system invokes ldgen.py, passing some information from the build.

The linker fragment files are parsed by fragments.py, evaluating conditional expressions with sdkconfig.py.

From the parsed fragments, generation.py generates output commands defined in output_commands.py, with some help from entity.py.

linker_script.py writes the output linker script, replacing markers with output commands generated.

More details about the implementation are in the respective source files.