Skip to content

Instantly share code, notes, and snippets.

@bluca
Created March 26, 2021 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluca/1fa56692456a022d411303a33267421d to your computer and use it in GitHub Desktop.
Save bluca/1fa56692456a022d411303a33267421d to your computer and use it in GitHub Desktop.
linker script to add custom note to elf - LDFLAGS="-Wl,-T,$PWD/script"
SECTIONS
{
.note.package : ALIGN(4) {
BYTE(0x04) BYTE(0x00) BYTE(0x00) BYTE(0x00) /* Length of Owner including NUL */
BYTE(0x4a) BYTE(0x00) BYTE(0x00) BYTE(0x00) /* Length of Value including NUL */
BYTE(0x00) BYTE(0x33) BYTE(0xdd) BYTE(0x7a) /* Note ID */
BYTE(0x54) BYTE(0x42) BYTE(0x44) BYTE(0x00) /* Owner: 'TBD\x00' */
BYTE(0x7b) BYTE(0x22) BYTE(0x70) BYTE(0x61) /* Value: '{"packageType":"deb","package":"fsverity-utils","packageVersion":"1.3-1"}\x00\x00\x00' */
BYTE(0x63) BYTE(0x6b) BYTE(0x61) BYTE(0x67)
BYTE(0x65) BYTE(0x54) BYTE(0x79) BYTE(0x70)
BYTE(0x65) BYTE(0x22) BYTE(0x3a) BYTE(0x22)
BYTE(0x64) BYTE(0x65) BYTE(0x62) BYTE(0x22)
BYTE(0x2c) BYTE(0x22) BYTE(0x70) BYTE(0x61)
BYTE(0x63) BYTE(0x6b) BYTE(0x61) BYTE(0x67)
BYTE(0x65) BYTE(0x22) BYTE(0x3a) BYTE(0x22)
BYTE(0x66) BYTE(0x73) BYTE(0x76) BYTE(0x65)
BYTE(0x72) BYTE(0x69) BYTE(0x74) BYTE(0x79)
BYTE(0x2d) BYTE(0x75) BYTE(0x74) BYTE(0x69)
BYTE(0x6c) BYTE(0x73) BYTE(0x22) BYTE(0x2c)
BYTE(0x22) BYTE(0x70) BYTE(0x61) BYTE(0x63)
BYTE(0x6b) BYTE(0x61) BYTE(0x67) BYTE(0x65)
BYTE(0x56) BYTE(0x65) BYTE(0x72) BYTE(0x73)
BYTE(0x69) BYTE(0x6f) BYTE(0x6e) BYTE(0x22)
BYTE(0x3a) BYTE(0x22) BYTE(0x31) BYTE(0x2e)
BYTE(0x33) BYTE(0x2d) BYTE(0x31) BYTE(0x22)
BYTE(0x7d) BYTE(0x00) BYTE(0x00) BYTE(0x00)
}
}
INSERT AFTER .note.gnu.build-id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment