[PATCH] D102039: [profile] Add binary id into profiles

Gulfem Savrun Yeniceri via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 10:31:38 PST 2021


gulfem added inline comments.


================
Comment at: compiler-rt/lib/profile/InstrProfilingPlatformLinux.c:178
+        (const ElfW(Nhdr) *)((const char *)(Note) + ProgramHeader[I].p_filesz);
+    return WriteBinaryIds(Writer, Note, NotesEnd);
+  }
----------------
vitalybuka wrote:
> Here is the problem
> This loop stops on the first PT_NOTE, even if it's not build-id
> e.g. .note.ABI-tag, check my log in the message above
`PT_NOTE` is the note segment in the program header, and that segment can have multiple notes (https://man7.org/linux/man-pages/man5/elf.5.html).
Like, the first note is `.note.ABI-tag`, and the second note is `.note.gnu.build-id` in your log.
When I run that locally, there are still two notes, but just the order is swapped.
```
gulfem at gulfem:~/llvm-release-build$ bin/llvm-readelf -n /usr/local/google/home/gulfem/llvm-release-build/projects/compiler-rt/test/profile/Profile-x86_64/Linux/Output/binary-id.c.tmp
Displaying notes found in: .note.gnu.build-id
  Owner                Data size        Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: 56559dcdb2c5b111e7e875c183ca2e0a1f433c96

Displaying notes found in: .note.ABI-tag
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 3.2.0
```

Here, we iterate through all the notes.
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c#L155
This should be iterating through all the notes in your case, too.
I'm looking at that code to see whether we are missing something else.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102039



More information about the llvm-commits mailing list