diff options
| author | Yogesh Tyagi <yogesh.tyagi@intel.com> | 2026-02-01 23:13:01 +0800 |
|---|---|---|
| committer | Yogesh Tyagi <yogesh.tyagi@intel.com> | 2026-02-02 00:08:03 +0800 |
| commit | 0763124558f0cef94660af2a724f03e2aeca1527 (patch) | |
| tree | 8e371205e7d9f9e47c6546c9cc1a0dc694a00403 | |
| parent | c43850a0a54e51b98f60cafd03babff1990592ad (diff) | |
| download | meta-intel-0763124558f0cef94660af2a724f03e2aeca1527.tar.gz | |
libipt: Switch from yasm to nasm assembler
Replace yasm with nasm as yasm is no longer maintained and has
unpatched CVEs (CVE-2024-45534, CVE-2024-45535). Nasm is actively
maintained and generates compatible listing files.
The patch includes:
- Changed assembler invocation from yasm to nasm
- Removed unsupported -L nasm parameter
- Added dual-format parser for org directives (yasm and nasm syntax)
- Implemented 1:1 line mapping fallback for nasm listing format
- Updated documentation
Both test cases (loop-tnt.ptt and dump-all-packets.ptt) now pass
on target system.
Upstream-Status: Submitted [https://github.com/intel/libipt/pull/120]
Signed-off-by: Yogesh Tyagi <yogesh.tyagi@intel.com>
| -rw-r--r-- | recipes-support/libipt/libipt/0001-pttc-use-nasm-instead-of-yasm.patch | 177 | ||||
| -rw-r--r-- | recipes-support/libipt/libipt_2.2.bb | 4 |
2 files changed, 180 insertions, 1 deletions
diff --git a/recipes-support/libipt/libipt/0001-pttc-use-nasm-instead-of-yasm.patch b/recipes-support/libipt/libipt/0001-pttc-use-nasm-instead-of-yasm.patch new file mode 100644 index 00000000..052d5aa6 --- /dev/null +++ b/recipes-support/libipt/libipt/0001-pttc-use-nasm-instead-of-yasm.patch | |||
| @@ -0,0 +1,177 @@ | |||
| 1 | From 2a62be5f20707d350e9be6406a853ecdf4be4051 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Yogesh Tyagi <yogesh.tyagi@intel.com> | ||
| 3 | Date: Sun, 1 Feb 2026 22:54:34 +0800 | ||
| 4 | Subject: [PATCH] pttc: Add support for nasm assembler | ||
| 5 | |||
| 6 | Replace yasm with nasm as the default assembler for pttc. Yasm is no | ||
| 7 | longer actively maintained and has known security vulnerabilities, while | ||
| 8 | nasm is actively developed and provides equivalent functionality. | ||
| 9 | |||
| 10 | Key changes: | ||
| 11 | 1. Update assembler invocation from 'yasm' to 'nasm' | ||
| 12 | 2. Remove '-L nasm' option (nasm doesn't need this flag) | ||
| 13 | 3. Adjust argv array indices after removing the flag | ||
| 14 | 4. Support both yasm and nasm org directive formats: | ||
| 15 | - yasm: [org 0x100000] | ||
| 16 | - nasm: org 0x100000 | ||
| 17 | 5. Handle nasm's listing format which lacks %line directives by | ||
| 18 | implementing 1:1 line mapping fallback for source correlation | ||
| 19 | |||
| 20 | The changes maintain backward compatibility with existing .ptt test files | ||
| 21 | while enabling nasm as the preferred assembler. | ||
| 22 | |||
| 23 | Tested with: | ||
| 24 | - test/src/loop-tnt.ptt | ||
| 25 | - test/src/dump-all-packets.ptt | ||
| 26 | |||
| 27 | Both tests generate valid PT traces that can be decoded with ptdump. | ||
| 28 | |||
| 29 | Upstream-Status: Submitted [https://github.com/intel/libipt/pull/120] | ||
| 30 | |||
| 31 | Signed-off-by: Yogesh Tyagi <yogesh.tyagi@intel.com> | ||
| 32 | --- | ||
| 33 | doc/howto_pttc.md | 6 ++--- | ||
| 34 | pttc/src/yasm.c | 63 +++++++++++++++++++++++++++++++++++++++-------- | ||
| 35 | 2 files changed, 56 insertions(+), 13 deletions(-) | ||
| 36 | |||
| 37 | diff --git a/doc/howto_pttc.md b/doc/howto_pttc.md | ||
| 38 | index e7308cdb..c356103b 100644 | ||
| 39 | --- a/doc/howto_pttc.md | ||
| 40 | +++ b/doc/howto_pttc.md | ||
| 41 | @@ -31,7 +31,7 @@ Testing the Intel(R) Processor Trace (Intel PT) Decoder Library and Samples {#pt | ||
| 42 | !--> | ||
| 43 | |||
| 44 | This chapter documents how to use the pttc tool to generate and run tests. | ||
| 45 | -Pttc takes a yasm assembly file and creates a Processor Trace stream from | ||
| 46 | +Pttc takes a nasm assembly file and creates a Processor Trace stream from | ||
| 47 | special directives in its input. | ||
| 48 | |||
| 49 | |||
| 50 | @@ -49,7 +49,7 @@ directory: | ||
| 51 | file-<tool>.exp | ||
| 52 | file-<src>.sb | ||
| 53 | |||
| 54 | -The `.lst` and `.bin` files are generated by a call to yasm. The `.pt` file | ||
| 55 | +The `.lst` and `.bin` files are generated by a call to nasm. The `.pt` file | ||
| 56 | contains the Processor Trace and the `.exp` files contain the content of the | ||
| 57 | comments after the `.exp` directive for tool `<tool>` (see below). The `.sb` | ||
| 58 | files contain sideband infomrmation from source `<src>` (see below). | ||
| 59 | @@ -60,7 +60,7 @@ Pttc prints the filenames of the generated `.exp` and `.sb` files to stdout. | ||
| 60 | Syntax | ||
| 61 | ------ | ||
| 62 | |||
| 63 | -Pttc allows annotations in the comments of yasm assembler source files. The | ||
| 64 | +Pttc allows annotations in the comments of nasm assembler source files. The | ||
| 65 | parser recognizes all comments that contain the `@pt` directive marker. | ||
| 66 | |||
| 67 | Every pt directive can be preceded by a label name followed by a colon (`:`). | ||
| 68 | diff --git a/pttc/src/yasm.c b/pttc/src/yasm.c | ||
| 69 | index 2f3020d1..98f6d846 100644 | ||
| 70 | --- a/pttc/src/yasm.c | ||
| 71 | +++ b/pttc/src/yasm.c | ||
| 72 | @@ -155,7 +155,7 @@ static int lookup_section_vstart(struct label *l, char *line, | ||
| 73 | } | ||
| 74 | |||
| 75 | static const char key_section[] = "[section"; | ||
| 76 | -static const char key_org[] = "[org"; | ||
| 77 | +static const char *key_org[] = {"[org", "org", NULL}; | ||
| 78 | |||
| 79 | int parse_yasm_labels(struct label *l, const struct text *t) | ||
| 80 | { | ||
| 81 | @@ -192,12 +192,33 @@ int parse_yasm_labels(struct label *l, const struct text *t) | ||
| 82 | continue; | ||
| 83 | } | ||
| 84 | |||
| 85 | - tmp = strstr(line, key_org); | ||
| 86 | - if (tmp) { | ||
| 87 | + /* Try both yasm format "[org" and nasm format "org" */ | ||
| 88 | + tmp = NULL; | ||
| 89 | + int org_style = -1; | ||
| 90 | + for (int j = 0; key_org[j] != NULL; j++) { | ||
| 91 | + tmp = strstr(line, key_org[j]); | ||
| 92 | + if (tmp) { | ||
| 93 | + org_style = j; | ||
| 94 | + break; | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + if (tmp && org_style >= 0) { | ||
| 99 | char *org; | ||
| 100 | |||
| 101 | - org = tmp + sizeof(key_org) - 1; | ||
| 102 | - tmp = strstr(org, "]"); | ||
| 103 | + org = tmp + strlen(key_org[org_style]); | ||
| 104 | + /* For yasm format "[org", look for ] */ | ||
| 105 | + if (org_style == 0) { | ||
| 106 | + tmp = strstr(org, "]"); | ||
| 107 | + } else { | ||
| 108 | + /* For nasm, skip whitespace to find hex value */ | ||
| 109 | + while (isspace(*org)) | ||
| 110 | + org++; | ||
| 111 | + tmp = org; | ||
| 112 | + /* Find end of hex number */ | ||
| 113 | + while (*tmp && !isspace(*tmp)) | ||
| 114 | + tmp++; | ||
| 115 | + } | ||
| 116 | if (!tmp) | ||
| 117 | return -err_no_org_directive; | ||
| 118 | |||
| 119 | @@ -720,18 +741,17 @@ error: | ||
| 120 | static int yasm_run(struct yasm *y) | ||
| 121 | { | ||
| 122 | char *argv[] = { | ||
| 123 | - "yasm", | ||
| 124 | + "nasm", | ||
| 125 | "<pttfile>", | ||
| 126 | "-f", "bin", | ||
| 127 | "-o", "<binfile>", | ||
| 128 | - "-L", "nasm", | ||
| 129 | "-l", "<lstfile>", | ||
| 130 | NULL, | ||
| 131 | }; | ||
| 132 | |||
| 133 | argv[1] = y->pttfile; | ||
| 134 | argv[5] = y->binfile; | ||
| 135 | - argv[9] = y->lstfile; | ||
| 136 | + argv[7] = y->lstfile; | ||
| 137 | |||
| 138 | return run(argv[0], argv); | ||
| 139 | } | ||
| 140 | @@ -825,9 +845,32 @@ static int yasm_advance_next_line(struct yasm *y) | ||
| 141 | /* if line number or increment in the previous line | ||
| 142 | * directive is <= 0, the current lst line has no | ||
| 143 | * corresponding line in the source file. | ||
| 144 | + * | ||
| 145 | + * For nasm compatibility: if no %line directives have been | ||
| 146 | + * seen yet, assume 1:1 mapping with source file. | ||
| 147 | */ | ||
| 148 | - if (y->st_asm->n <= 0 || y->st_asm->inc <= 0) | ||
| 149 | - continue; | ||
| 150 | + if (y->st_asm->n <= 0 || y->st_asm->inc <= 0) { | ||
| 151 | + /* If we haven't seen any %line directive, try to use | ||
| 152 | + * the source file directly with 1:1 line mapping. | ||
| 153 | + */ | ||
| 154 | + if (!y->st_asm->filename || y->st_asm->filename[0] == '\0') { | ||
| 155 | + /* Set to source .ptt file for first time */ | ||
| 156 | + st_set_file(y->st_asm, y->pttfile, 1, 1); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + /* Calculate source line from listing line for nasm */ | ||
| 160 | + asm_line = (int)y->lst_curr_line; | ||
| 161 | + | ||
| 162 | + /* Read from source file at same line number */ | ||
| 163 | + errcode = fl_getline(y->fl, s, (size_t) sizeof(s), | ||
| 164 | + y->st_asm->filename, | ||
| 165 | + (size_t) asm_line - 1u); | ||
| 166 | + if (errcode < 0) | ||
| 167 | + continue; /* Skip if can't read source line */ | ||
| 168 | + | ||
| 169 | + errcode = st_update(y->st_asm, s); | ||
| 170 | + break; | ||
| 171 | + } | ||
| 172 | |||
| 173 | /* finally the current line in the lst file can be | ||
| 174 | * correlated to the source file, so we retrieve the | ||
| 175 | -- | ||
| 176 | 2.34.1 | ||
| 177 | |||
diff --git a/recipes-support/libipt/libipt_2.2.bb b/recipes-support/libipt/libipt_2.2.bb index ca1edb7f..47f74f68 100644 --- a/recipes-support/libipt/libipt_2.2.bb +++ b/recipes-support/libipt/libipt_2.2.bb | |||
| @@ -9,7 +9,9 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=fcee2b5da70c8e2e58c5f4d1f2d5788a" | |||
| 9 | 9 | ||
| 10 | inherit pkgconfig cmake | 10 | inherit pkgconfig cmake |
| 11 | 11 | ||
| 12 | SRC_URI = "git://github.com/intel/libipt.git;protocol=https;branch=stable/v2.2" | 12 | SRC_URI = "git://github.com/intel/libipt.git;protocol=https;branch=stable/v2.2 \ |
| 13 | file://0001-pttc-use-nasm-instead-of-yasm.patch \ | ||
| 14 | " | ||
| 13 | 15 | ||
| 14 | SRCREV = "eecdf779a35384235d3c32a6213024f53368cb60" | 16 | SRCREV = "eecdf779a35384235d3c32a6213024f53368cb60" |
| 15 | 17 | ||
