[llvm] [RISCV] Improvements to .note.gnu.property section. (PR #151436)
Jesse Huang via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 07:12:15 PDT 2025
================
@@ -83,29 +86,21 @@ void RISCVTargetStreamer::emitNoteGnuPropertySection(
OutStreamer.switchSection(NoteSection);
// Emit the note header
- OutStreamer.emitIntValue(4, 4); // n_namsz
-
- MCSymbol *const NDescBeginSym = Ctx.createTempSymbol();
- MCSymbol *const NDescEndSym = Ctx.createTempSymbol();
- const MCExpr *const NDescSzExpr =
- MCBinaryExpr::createSub(MCSymbolRefExpr::create(NDescEndSym, Ctx),
- MCSymbolRefExpr::create(NDescBeginSym, Ctx), Ctx);
-
- OutStreamer.emitValue(NDescSzExpr, 4); // n_descsz
+ OutStreamer.emitValueToAlignment(NoteAlign);
----------------
jaidTw wrote:
My "note" here does not mean `desc`, I mean the whole (`namesz`, `descsz`, `type`, `name`, `desc`) structure.
There is a figure in your link that shows the alignment of two notes, which `desc` is absent in the first note. This means it is possible to have several nodes stacked one by another. So **"the next note entry"** could also be the starting address of the next note (which is `namesz`)
<img width="373" height="318" alt="圖片" src="https://github.com/user-attachments/assets/a5b1322a-8084-47de-94c7-6ee667e0b181" />
I believe we are safe to assume every note is well-aligned (I reviewed glibc/binutils and they also have the note alignment check), instead of using `desc` as the basis of alignment.
With you suggestions, I think we can
1. Remove the section alignment
2. Align at the beginning of the note (which this patch is doing)
3. For the trailing padding, I have no strong opinions on using `emitIntValue` or `emitValueToAlignment`
https://github.com/llvm/llvm-project/pull/151436
More information about the llvm-commits
mailing list