From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YOpT1-0003FZ-Jn for mharc-grub-devel@gnu.org; Fri, 20 Feb 2015 10:26:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOpT0-0003FR-6g for grub-devel@gnu.org; Fri, 20 Feb 2015 10:26:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOpSz-0002gH-1h for grub-devel@gnu.org; Fri, 20 Feb 2015 10:26:10 -0500 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:42327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOpSy-0002g4-Qh for grub-devel@gnu.org; Fri, 20 Feb 2015 10:26:08 -0500 Received: by mail-wi0-f173.google.com with SMTP id bs8so3719592wib.0 for ; Fri, 20 Feb 2015 07:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=lS3sDH3HfzP9+uWJ9ToOk1PYLxS0savnfMR9kmrAnuM=; b=qTMJoZg5b3kwcQ7xpQST4dVBqA+9XcsIVdR70SaT0g5sKuK5yHTax1pdLwMCElpJ+c tbczOqgPA2BSewjqOwokSZgh4KKdev6nR/GGW8gdyK5yrANaNE90F4kVweiXk+h22Zku 4ghDCcrwsWp5uGJYlequKHjiSzrzBOA6QmEcycIiy0roCnRkvu1FyQjxnGCRiyUHBuU4 3fdHQfnLzVGIwcBhZUdAi7kpyhPGeibseXyLdl13sNZfdhtpqeI+3hwjYp4UpcHx2Qfe 8ow8o6Gt+u4jW7EXFfoKMC7m9J1y4fNmsXk56vJPoQYHhvYHhKP5HsCSMy6CYPb3Y6+X /m0w== X-Received: by 10.180.24.65 with SMTP id s1mr20602155wif.30.1424445968234; Fri, 20 Feb 2015 07:26:08 -0800 (PST) Received: from ?IPv6:2620:0:105f:fd00:202:52ff:fe61:c42e? ([2620:0:105f:fd00:202:52ff:fe61:c42e]) by mx.google.com with ESMTPSA id a1sm42509602wjs.40.2015.02.20.07.26.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Feb 2015 07:26:07 -0800 (PST) Message-ID: <54E7520F.8070601@gmail.com> Date: Fri, 20 Feb 2015 16:26:07 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 MIME-Version: 1.0 To: dwmw2@infradead.org, llvmdev@cs.uiuc.edu, The development of GRUB 2 Subject: Re: clang .code16 with -Os producing larger code that it needs to References: <54E74B9D.8090605@gmail.com> In-Reply-To: <54E74B9D.8090605@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="DuGpKNUx3cqFG5r8g4ahNxBqeF1QQCiLP" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Feb 2015 15:26:11 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --DuGpKNUx3cqFG5r8g4ahNxBqeF1QQCiLP Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 20.02.2015 15:58, Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: > When experimenting with compiling GRUB2 with clang using integrated as,= > I found out that it generates a 16-bit code bigger than gas counterpart= > and result gets too big for size constraints of bootsector. This was > traced mainly to 2 problems. > 32-bit access to 16-bit addresses. > source: > movl LOCAL(kernel_sector), %ebx > movl %ebx, 8(%si) > clang: > 7cbc: 67 66 8b 1d 5c 7c 00 addr32 mov 0x7c5c,%ebx > 7cc3: 00 > 7cc4: 66 89 5c 08 mov %ebx,0x8(%si) >=20 > gas: > 7cbc: 66 8b 1e 5c 7c mov 0x7c5c,%ebx > 7cc1: 66 89 5c 08 mov %ebx,0x8(%si) > 32-bit jump. > source: > jnb LOCAL(floppy_probe) > clang: > + 7cb5: 66 0f 83 07 01 00 00 jae 7dc3 > gas: > - 7cb5: 0f 83 0a 01 jae 7dc3 Minimal example would be: .code16 jmp 1f .space 256 1: nop clang: 0: 66 e9 00 01 00 00 jmpl 0x106 ... 106: 90 nop gcc: 0: e9 00 01 jmp 0x103 ... 103: 90 nop > The last one is particularly problematic as it never makes sense to > issue 32-bit jump if %ip is only 16 bits and it eats 3 extra bytes per > jump. Is it possible to force clang to generate 16-bit jumps? > On bright side if I remove error strings the code is functional. >=20 --DuGpKNUx3cqFG5r8g4ahNxBqeF1QQCiLP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iF4EAREKAAYFAlTnUg8ACgkQmBXlbbo5nOttSQEAj44+igjHmJ6ydNBpxEQhhSym 3BgB6+vl7eIBo9TR96QA/2dfMZf/XKFYyRWhNBsIRJFCkLkZ3Vv1PvNQ7C1B7/WM =wetI -----END PGP SIGNATURE----- --DuGpKNUx3cqFG5r8g4ahNxBqeF1QQCiLP--