grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] elf: accept elf files without section header table
Date: Fri, 3 May 2024 19:42:04 +0300	[thread overview]
Message-ID: <CAEaD8JM0CRRVwLs0o228NipOA5h1jUqmT2=F8n_xOJHQFsFu9A@mail.gmail.com> (raw)
In-Reply-To: <53fe173b-a348-4621-b7d1-a9a63398cef8@neutrality.ch>


[-- Attachment #1.1: Type: text/plain, Size: 1615 bytes --]

Hey. Can you describe what exactly are you trying to solve?

Le ven. 3 mai 2024, 17:46, Mathieu Mirmont <mat@neutrality.ch> a écrit :

> It isn't an error for an elf executable to be lacking a section header
> table. In this case we should just be returning shnum = 0.
>
> According to the elf(5) manual page:
> "
> e_shoff  This member holds the section header table's file offset in
>            bytes. If the file has no section header table, this member
>            holds zero.
> "
>
> Signed-off-by: Mathieu Mirmont <mat@neutrality.ch>
> ---
>   grub-core/kern/elfXX.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c
> index aabf4b9d7..fe4ffb261 100644
> --- a/grub-core/kern/elfXX.c
> +++ b/grub-core/kern/elfXX.c
> @@ -220,12 +220,12 @@ grub_elfXX_get_shnum (ElfXX_Ehdr *e, ElfXX_Shnum
> *shnum)
>     if (e == NULL)
>       return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("NULL pointer passed
> for elf header"));
>
> +  if (e->e_shoff == 0)
> +    return GRUB_ERR_NONE;
> +
>     *shnum = e->e_shnum;
>     if (*shnum == SHN_UNDEF)
>       {
> -      if (e->e_shoff == 0)
> -
> return grub_error (GRUB_ERR_BAD_NUMBER, N_("invalid section header
> table offset in e_shoff"));
> -
>         s = (ElfXX_Shdr *) ((grub_uint8_t *) e + e->e_shoff);
>         *shnum = s->sh_size;
>         if (*shnum < SHN_LORESERVE)
> --
> 2.30.2
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #1.2: Type: text/html, Size: 2337 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

      reply	other threads:[~2024-05-03 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 14:35 [PATCH] elf: accept elf files without section header table Mathieu Mirmont
2024-05-03 16:42 ` Vladimir 'phcoder' Serbinenko [this message]

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='CAEaD8JM0CRRVwLs0o228NipOA5h1jUqmT2=F8n_xOJHQFsFu9A@mail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).