blob: ae17f47cd4e67d4d94453ba5250969ef8febe11d [file] [log] [blame]
Wyatt Heplerd58eef92020-05-08 10:39:56 -07001/*
2 * Copyright 2020 The Pigweed Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
Wyatt Heplereb020a12020-10-28 14:01:51 -070015 */
16
17/*
Wyatt Heplerd58eef92020-05-08 10:39:56 -070018 *
19 * This linker script snippet declares the sections needed for string
20 * tokenization. All sections have type INFO so they are excluded from the final
21 * binary.
22 *
23 * The contents of this script can be copied into an existing linker script.
24 * Alternately, this file can be directly included in a linker script with an
25 * include directive. For example,
26 *
27 * INCLUDE path/to/modules/pw_tokenizer/pw_tokenizer_linker_sections.ld
28 *
29 * SECTIONS
30 * {
31 * (your existing linker sections)
32 * }
33 */
34
35SECTIONS
36{
37 /*
38 * This section stores metadata that may be used during tokenized string
39 * decoding. This metadata describes properties that may affect how the
40 * tokenized string is encoded or decoded -- the maximum length of the hash
41 * function and the sizes of certain integer types.
42 *
43 * Metadata is declared as key-value pairs. See the metadata variable in
44 * tokenize.cc for further details.
45 */
Wyatt Heplereb020a12020-10-28 14:01:51 -070046 .pw_tokenizer.info 0x0 (INFO) :
Wyatt Heplerd58eef92020-05-08 10:39:56 -070047 {
Wyatt Heplereb020a12020-10-28 14:01:51 -070048 KEEP(*(.pw_tokenizer.info))
Wyatt Heplerd58eef92020-05-08 10:39:56 -070049 }
50
51 /*
Wyatt Heplereb020a12020-10-28 14:01:51 -070052 * Tokenized string entries are stored in this section. Each entry contains
53 * the original string literal and the calculated token that represents it. In
54 * the compiled code, the token and a compact argument list encoded in a
55 * uint32_t are used in place of the format string. The compiled code
56 * contains no references to the tokenized string entries in this section.
57 *
58 * The tokenized string entry format is specified by the
59 * pw::tokenizer::internal::Entry class in
60 * pw_tokenizer/public/pw_tokenizer/internal/tokenize_string.h.
Wyatt Heplerd58eef92020-05-08 10:39:56 -070061 *
62 * The section contents are declared with KEEP so that they are not removed
63 * from the ELF. These are never emitted in the final binary or loaded into
64 * memory.
65 */
Wyatt Heplereb020a12020-10-28 14:01:51 -070066 .pw_tokenizer.entries 0x0 (INFO) :
Wyatt Heplerd58eef92020-05-08 10:39:56 -070067 {
Wyatt Heplereb020a12020-10-28 14:01:51 -070068 KEEP(*(.pw_tokenizer.entries.*))
Wyatt Heplerd58eef92020-05-08 10:39:56 -070069 }
Wyatt Heplerd58eef92020-05-08 10:39:56 -070070}