From: Thiago Jung Bauermann <bauerman@br.ibm.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH/RFC] auxv entries
Date: Mon, 15 Sep 2008 00:28:00 -0000 [thread overview]
Message-ID: <1221438424.17278.11.camel@localhost.localdomain> (raw)
In-Reply-To: <200809142127.m8ELR9eX025288@brahms.sibelius.xs4all.nl>
El dom, 14-09-2008 a las 23:27 +0200, Mark Kettenis escribió:
> Many, if not all, processor-specific ELF ABI documents have the
> following definition of auxv entries:
>
> typedef struct
> {
> int a_type;
> union {
> long a_val;
> void *a_ptr;
> void (*a_fcn)();
> } a_un;
> } auxv_t;
This is what I see in <elf.h> on ppc64-linux:
>
> This is not the layout that default_auxv_parse() uses though, which is
> wrong for big-endian 64-bit systems. The attached diff fixes this,
> making the assumption that a_val is "naturally" aligned.
>
> I have some slight worries though about how this ever worked on
> big-endian 64-bit Linux systems, hence the RFC.
>
>
> Index: ChangeLog
> from Mark Kettenis <kettenis@gnu.org>
>
> * auxv.c (default_auxv_parse): Change code to reflect standard
> auxv_t layout.
>
> Index: auxv.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/auxv.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 auxv.c
> --- auxv.c 11 Sep 2008 14:29:21 -0000 1.14
> +++ auxv.c 14 Sep 2008 21:20:03 -0000
> @@ -82,20 +82,22 @@ int
> default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
> gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
> {
> - const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
> - / TARGET_CHAR_BIT;
> + struct type *builtin_int = builtin_type (target_gdbarch)->builtin_int;
> + struct type *builtin_long = builtin_type (target_gdbarch)->builtin_long;
> + const int sizeof_auxv_type = TYPE_LENGTH(builtin_int);
> + const int sizeof_auxv_val = TYPE_LENGTH(builtin_long);
> gdb_byte *ptr = *readptr;
>
> if (endptr == ptr)
> return 0;
>
> - if (endptr - ptr < sizeof_auxv_field * 2)
> + if (endptr - ptr < sizeof_auxv_val * 2)
> return -1;
>
> - *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
> - ptr += sizeof_auxv_field;
> - *valp = extract_unsigned_integer (ptr, sizeof_auxv_field);
> - ptr += sizeof_auxv_field;
> + *typep = extract_unsigned_integer (ptr, sizeof_auxv_type);
> + ptr += sizeof_auxv_val; /* Alignment. */
> + *valp = extract_unsigned_integer (ptr, sizeof_auxv_val);
> + ptr += sizeof_auxv_val;
>
> *readptr = ptr;
> return 1;
>
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center
next prev parent reply other threads:[~2008-09-15 0:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-14 21:27 Mark Kettenis
2008-09-15 0:28 ` Thiago Jung Bauermann [this message]
2008-09-15 0:34 ` Thiago Jung Bauermann
2008-09-15 9:21 ` Mark Kettenis
2008-09-15 20:23 ` Mark Kettenis
2008-09-15 21:14 ` Daniel Jacobowitz
2008-09-16 3:28 ` Thiago Jung Bauermann
2008-09-15 3:21 ` Daniel Jacobowitz
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=1221438424.17278.11.camel@localhost.localdomain \
--to=bauerman@br.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
/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