[SYCL]Fix objdump's bug on macho arm64 when adrp's imm < 0 #2499
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
I used the same
llvm-objdump -S -m --section=<section name> <macho-file>
command for two different macho files to see the disassembly code.But the annotation for the assembly instruction can't show for the second file, as shown on the right.
Here is the two files which you can test:
the two macho files.zip
Reason
I found this to be a bug if the adrp's imm < 0, at the followed lines:
The line adrp_imm = ((info->adrp_inst & 0x00ffffe0) >> 3) | ((info->adrp_inst >> 29) & 0x3) find the adrp_imm in adrp_inst, it's right.
And the next two lines are intended to:
However, as shown in the picture:

adrp_imm is encoded as [23:5][31:29].
If you want to determine if adrp_imm is a negative number, you should determine the 23rd bit of adrp_inst, or the 20th bit of adrp_imm.
It will not be info->adrp_inst & 0x0200000. The 0x0200000 is 0b00000000001000000000000000000000,the code is to determine the 21st of adrp_inst,so it doesn't make any sense.
This code
adrp_imm |= 0xfffffffffc000000LL
is also wrong, it caculated the wrong bits.Fix
Use the follow code to fix:
validation
After the correction, I got the result I wanted.