Page MenuHomeFreeBSD

Clang groks .codeNN; remove CLANG_NO_IAS from sys/boot/i386
ClosedPublic

Authored by emaste on Jun 9 2017, 4:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 17 2024, 6:24 PM
Unknown Object (File)
Jan 24 2024, 7:51 AM
Unknown Object (File)
Jan 13 2024, 5:03 AM
Unknown Object (File)
Jan 9 2024, 10:07 AM
Unknown Object (File)
Dec 20 2023, 2:40 AM
Unknown Object (File)
Dec 14 2023, 9:54 PM
Unknown Object (File)
Nov 28 2023, 6:50 PM
Unknown Object (File)
Nov 28 2023, 6:49 PM
Subscribers

Details

Summary

It was added in rS218893 as part of a Clang update. The new Clang version added the x86 integrated assembler but did not support .codeNN directives. .codeNN support has now been available in Clang for quite some time and there is no need to disable the integrated assembler.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I think this is a good idea, but the last time I tried this, I compared the resulting object files, and I did see a bunch of differences with the output of gas. Is that still the case? It may just be due to a slightly different interpretation of prefixes and the like, but it is important to make sure that everything still boots after this change. :)

In D11115#230152, @dim wrote:

I think this is a good idea, but the last time I tried this...

Yes important point - now I seem to recall we spoke about this in the past and you pointed this out but I can't find details. Perhaps it was on IRC. I have been running a similar patch in test trees for quite some time, but will do a more detailed comparison of the differences.

In D11115#230152, @dim wrote:

I think this is a good idea, but the last time I tried this...

Yes important point - now I seem to recall we spoke about this in the past and you pointed this out but I can't find details. Perhaps it was on IRC. I have been running a similar patch in test trees for quite some time, but will do a more detailed comparison of the differences.

so long as we still boot, I'm cool. I'd be cooler if at least one of these .S files had a side by side comparison with the .o generated.... they should be substantially the same if not identical.

In D11115#230181, @imp wrote:

so long as we still boot, I'm cool. I'd be cooler if at least one of these .S files had a side by side comparison with the .o generated.... they should be substantially the same if not identical.

I did not test or compare all of the resulting objects initially, and when I did later on I found a few issues of concern. I may try incrementally removing these, comparing object files and either finding them identical or at least having understandable differences.

emaste retitled this revision from Clang groks .codeNN; remove CLANG_NO_AS from sys/boot/i386 to Clang groks .codeNN; remove CLANG_NO_IAS from sys/boot/i386.Jun 13 2017, 1:57 PM

@dim compared in-tree gas and Clang 5.0 IAS and found a few differences in boot0:
gas: 81 c7 06 00 add $0x6,%di ias: 83 c7 06 add $0x6,%di
gas: 05 be 07 add $0x7be,%ax ias: 81 c0 be 07 add $0x7be,%ax
(and related offset changes)

Update with rebased patch; some parts of this have been committed already.

rebase, dropping zfs change already committed

side by side comparison with the .o generated

Looking at boot1.o differences there are lots of header, debug, etc. changes, and changes due to differing offsets. The real change is different instruction size for the test instruction at the beginning of read

read:           testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?

GNU as produces

0000:012e      2e f6 06 b0 08 80   test byte cs:[0x8b0], 0x80   ; [0x8b0:1]=255 ; 128

While Clang IAS produces:

0000:012e      2e 67 f6 05 b3 08 00 00 80  test byte cs:[0x8b3], 0x80   ; [0x8b3:1]=255 ; 128

This is fine for boot2, other than using three bytes more than necessary.

side by side comparison with the .o generated

Looking at boot1.o differences there are lots of header, debug, etc. changes, and changes due to differing offsets. The real change is different instruction size for the test instruction at the beginning of read

read:           testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?

GNU as produces

0000:012e      2e f6 06 b0 08 80   test byte cs:[0x8b0], 0x80   ; [0x8b0:1]=255 ; 128

While Clang IAS produces:

0000:012e      2e 67 f6 05 b3 08 00 00 80  test byte cs:[0x8b3], 0x80   ; [0x8b3:1]=255 ; 128

This is fine for boot2, other than using three bytes more than necessary.

If this is the only change, we can commit. boot1.o isn't in danger of running out of it's 512byte limited space, so we don't have to do special things.

None of the others have space concerns at all worth noting. Do we know if the differences are similar there as well?

Do we know if the differences are similar there as well?

I believe so - the same issue is present in the others, but I have not yet confirmed that it's the only source of differences.

cdboot differences are a large number of addr32 prefixes and using nop nop for alignment rather than xchg %eax,%eax, so it is ok too

rebase after committing boot2 and cdboot changes

need to confirm that pxeboot and gptzfsboot are also only instruction size differences before committing those

all other boot components have been addressed; only gptzfsboot needs to be investigated now

As it turns out gptzfsboot is identical, whether GAS or IAS is used to assemble gptldr.S:

SHA256 (gas/gptzfsboot) = bc732937deaf7fd5c2d2bcaa1ec426d6f5e2c7bbf50922930f49a397cdec9820
SHA256 (ias/gptzfsboot) = bc732937deaf7fd5c2d2bcaa1ec426d6f5e2c7bbf50922930f49a397cdec9820

gptldr.o .text is identical, differences between gas and IAS are

  • ELF headers
  • DWARF debug info (Clang IAS adds it)
  • some minor differences in symbols and relocations
  • string table differences due to additional sections etc.
This revision was not accepted when it landed; it landed in state Needs Review.Aug 15 2019, 6:43 PM
This revision was automatically updated to reflect the committed changes.