This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][test] Add MachO simple tests
Needs ReviewPublic

Authored by rafauler on Apr 24 2023, 5:48 PM.

Details

Reviewers
Amir
maksfb
alexander-shaposhnikov
Group Reviewers
Restricted Project
Summary

Push some basic tests for BOLT and MachO

Diff Detail

Event Timeline

rafauler created this revision.Apr 24 2023, 5:48 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
rafauler requested review of this revision.Apr 24 2023, 5:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 5:48 PM

Most binaries here are 4KB, largest one is 80KB. If we don't want to push this to LLVM, we can push them to github.com/rafaelauler/bolt-tests

jobnoorman added inline comments.
bolt/test/X86/MachO/emit_new_binary_with_external_symbol.test
13

This seems wrong. In the original binary, this is a call to 0x100000f96.

llvm-objdump --macho --disassemble-all --no-print-imm-hex bolt/test/X86/MachO/Inputs/external_symbol.exe
/home/job/dev/llvm-project/bolt/test/X86/MachO/Inputs/external_symbol.exe:
(__TEXT,__text) section
_main:
100000f50:	55	pushq	%rbp
100000f51:	48 89 e5	movq	%rsp, %rbp
100000f54:	48 83 ec 20	subq	$32, %rsp
100000f58:	c7 45 fc 00 00 00 00	movl	$0, -4(%rbp)
100000f5f:	89 7d f8	movl	%edi, -8(%rbp)
100000f62:	48 89 75 f0	movq	%rsi, -16(%rbp)
100000f66:	83 7d f8 01	cmpl	$1, -8(%rbp)
100000f6a:	0f 8e 0d 00 00 00	jle	0x100000f7d
100000f70:	e8 21 00 00 00	callq	0x100000f96 ## symbol stub for: _f
100000f75:	89 45 fc	movl	%eax, -4(%rbp)
100000f78:	e9 10 00 00 00	jmp	0x100000f8d
100000f7d:	c7 45 ec 01 00 00 00	movl	$1, -20(%rbp)
100000f84:	8b 45 ec	movl	-20(%rbp), %eax
100000f87:	83 c0 02	addl	$2, %eax
100000f8a:	89 45 fc	movl	%eax, -4(%rbp)
100000f8d:	8b 45 fc	movl	-4(%rbp), %eax
100000f90:	48 83 c4 20	addq	$32, %rsp
100000f94:	5d	popq	%rbp
100000f95:	c3	retq
51

Same as above.