All of lore.kernel.org
 help / color / mirror / Atom feed
From: phcoder <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [Fwd: Re: ELF bugfixes]
Date: Thu, 12 Mar 2009 14:22:28 +0100	[thread overview]
Message-ID: <49B90C94.4070302@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]


-- 

Regards
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: Re: ELF bugfixes.eml --]
[-- Type: message/rfc822, Size: 2597 bytes --]

From: phcoder <phcoder@gmail.com>
To: David Miller <davem@davemloft.net>
Subject: Re: ELF bugfixes
Date: Thu, 12 Mar 2009 14:21:45 +0100
Message-ID: <49B90C69.60703@gmail.com>

David Miller wrote:
> From: phcoder <phcoder@gmail.com>
> Date: Thu, 12 Mar 2009 12:22:15 +0100
> 
>> David Miller wrote:
>>> From: phcoder <phcoder@gmail.com>
>>> Date: Thu, 12 Mar 2009 09:23:34 +0100
>>>
>>>> Index: include/grub/elf.h
>>>> ===================================================================
>>>> --- include/grub/elf.h	(revision 2036)
>>>> +++ include/grub/elf.h	(working copy)
>>>> @@ -77,7 +77,7 @@
>>>>    Elf32_Half	e_shentsize;		/* Section header table entry size */
>>>>    Elf32_Half	e_shnum;		/* Section header table entry count */
>>>>    Elf32_Half	e_shstrndx;		/* Section header string table index */
>>>> -} Elf32_Ehdr;
>>>> +} __attribute__ ((packed)) Elf32_Ehdr;
>>>>  
>>> There is no reason why you should need the packed attribute here.
>>> I can't think of any cpu where this could even remotely be necessary.
>>> And if it's not necessary, all it does it emit terribly suboptimal
>>> code on RISC cpus.
>> If it doesn't make a difference in the structure why does the compiler generate different code?
> 
> Because packed also means that the alignment of the structure
> can't be assumed to be naturally word aligned.  So the compiler
> has to use byte loads and stores to load a word, for example,
> on RISC machines.
> 
> This is because the packed attribute influences how the structure is
> embedded into other structures.
> 
> This attribute controls two different things, not just local packing.

I knew it but normally when you parse files normally offsets aren't 
guaranteed to be aligned. But now it seems that elf parser is written in 
a way to guarantee at least some alignments. Then this part of patch 
probably is to be dropped or changed to proper aligned attribute

-- 

Regards
Vladimir 'phcoder' Serbinenko

             reply	other threads:[~2009-03-12 13:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12 13:22 phcoder [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-03-13 20:54 [Fwd: Re: ELF bugfixes] phcoder

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=49B90C94.4070302@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /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.