From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: dwmw2@infradead.org, llvmdev@cs.uiuc.edu,
The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: clang .code16 with -Os producing larger code that it needs to
Date: Fri, 20 Feb 2015 16:26:07 +0100 [thread overview]
Message-ID: <54E7520F.8070601@gmail.com> (raw)
In-Reply-To: <54E74B9D.8090605@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]
On 20.02.2015 15:58, Vladimir 'φ-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)
>
> 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 <L_floppy_probe>
> gas:
> - 7cb5: 0f 83 0a 01 jae 7dc3 <L_floppy_probe>
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.
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
next prev parent reply other threads:[~2015-02-20 15:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 14:58 clang .code16 with -Os producing larger code that it needs to Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-20 15:26 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2015-02-20 15:38 ` David Woodhouse
2015-02-20 15:46 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-20 16:05 ` David Woodhouse
2015-02-20 16:18 ` David Woodhouse
2015-02-20 18:47 ` [LLVMdev] " Rafael Espíndola
2015-02-23 12:07 ` David Woodhouse
2015-02-24 8:42 ` Craig Topper
2015-02-24 9:07 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54E7520F.8070601@gmail.com \
--to=phcoder@gmail.com \
--cc=dwmw2@infradead.org \
--cc=grub-devel@gnu.org \
--cc=llvmdev@cs.uiuc.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.