Skip to content

Instantly share code, notes, and snippets.

@aljimenezb
Last active March 24, 2020 18:29
Show Gist options
  • Save aljimenezb/9918b8562070cb89ab6696025305e3f9 to your computer and use it in GitHub Desktop.
Save aljimenezb/9918b8562070cb89ab6696025305e3f9 to your computer and use it in GitHub Desktop.
Revised elfnote tests for PVH boot

With the changes proposed by rust-vmm/linux-loader#29, the test_badnote.bin and test_elfnote.bin binaries must be modified to use the correct name of "Xen" for the note header, as the PVH ABI specifies. I'm uploading the source files and the resulting binaries here. Built with:

gcc elfnote.S -s -nostdlib -o test_elfnote.bin

gcc badnote.S -s -nostdlib -o test_badnote.bin

#define ELFNOTE_START(name, type, flags) \
.pushsection .note.name, flags, @note ; \
.balign 4 ; \
.long 2f - 1f /* namesz */ ; \
.long 4484f - 3f /* descsz */ ; \
.long type ; \
1:.asciz #name ; \
2:.balign 4 ; \
3:
#define ELFNOTE_END \
4484:.balign 4 ; \
.popsection ;
#define ELFNOTE(name, type, desc) \
ELFNOTE_START(name, type, "a") \
desc ; \
ELFNOTE_END
#define XEN_ELFNOTE_PHYS32_ENTRY 18
#define NT_VERSION 1
ELFNOTE(dummy, NT_VERSION, .quad 0xcafecafe)
ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .word 0x1e1f)
.section ".text","ax"
.global _start
_start:
#define ELFNOTE_START(name, type, flags) \
.pushsection .note.name, flags, @note ; \
.balign 4 ; \
.long 2f - 1f /* namesz */ ; \
.long 4484f - 3f /* descsz */ ; \
.long type ; \
1:.asciz #name ; \
2:.balign 4 ; \
3:
#define ELFNOTE_END \
4484:.balign 4 ; \
.popsection ;
#define ELFNOTE(name, type, desc) \
ELFNOTE_START(name, type, "a") \
desc ; \
ELFNOTE_END
#define XEN_ELFNOTE_PHYS32_ENTRY 18
#define NT_VERSION 1
ELFNOTE(dummy, NT_VERSION, .quad 0xcafecafe)
ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .quad 0x1e1fe1f)
.section ".text","ax"
.global _start
_start:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment