[PATCH] D119384: [MTE] [lld] Add --memtag-* options to synthetise ELF notes.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 00:41:39 PST 2022


MaskRay added a comment.

I know little about MTE. Do you have a companion Bionic change? If yes, seems useful to share the link here so that people will see the big picture.

Currently `--memtag-*` seems Android specific while Android specific options should have `android` in the names.
If `--memtag-*` may be used by regular AArch64 programs, then using `--memtag-*` seems fine.

Do you expect further iterations on the option semantics? Do we reserve rights to rename and adjust semantics as appropriate, and try having little backward compatibility burden?



================
Comment at: lld/ELF/SyntheticSections.cpp:3851
+
+  write32(buf, sizeof(kMemtagAndroidNoteName));        // nhdr.n_namesz
+  write32(buf + 4, sizeof(uint32_t));                  // nhdr.n_descsz
----------------
This section is modeled on Elf64_Nhdr, so it's clear these fields are related to `nhdr`. No need to mention this again.


================
Comment at: lld/ELF/SyntheticSections.cpp:3853
+  write32(buf + 4, sizeof(uint32_t));                  // nhdr.n_descsz
+  write32(buf + 8, llvm::ELF::NT_ANDROID_TYPE_MEMTAG); // nhdr.n_type
+  memcpy(buf + 12, kMemtagAndroidNoteName,             // name string
----------------



================
Comment at: lld/test/ELF/aarch64-memtag-android-abi.s:3
+
+## Old versions of Android (Android 11 & 12) have very strict parsing logic on
+## the layout of the ELF note. This test serves as a "hey, you're going to break
----------------
This block of comments may be confusing to readers. Are the tags added to serve backward compatibility purposes for the old versions of Android, or are they needed by new Android?


================
Comment at: lld/test/ELF/aarch64-memtag-android-abi.s:9
+## libraries or headers, this should be runnable on any system that uses linux
+## (technically, any system that can parse ELF, but I'm not rewriting it in
+## python to run on Windows...). Note that MTE stack is an ABI break, so we
----------------
> (technically, any system that can parse ELF, but I'm not rewriting it in python to run on Windows...).

This sentence can be removed.

llvm-readelf -n is a robust way testing ELF note sections. There seems no point to use Python to dump the information.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119384/new/

https://reviews.llvm.org/D119384



More information about the llvm-commits mailing list