[llvm] [RISCV] Improvements to .note.gnu.property section. (PR #151436)
Jesse Huang via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 01:52:41 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:
> # descsz and desc
> The first descsz bytes in desc hold the note descriptor. The ABI places no constraints on a descriptor's contents. If no descriptor is present, descsz contains 0. **Padding is present, if necessary, to ensure 8 or 4-byte alignment for the next note entry (depending on whether the file is a 64-bit or 32-bit object).** Such padding is not included in descsz.
>
Thanks for mentioning the spec requirement.
I wonder based on the statement **Padding is present, if necessary, to ensure 8 or 4-byte alignment for the next note entry**. Can we also infer that the every note (hence the SHT_NOTE section) has to be aligned?
https://github.com/llvm/llvm-project/pull/151436
More information about the llvm-commits
mailing list