[PATCH v3 03/13] Rewrite abi-note.S in C.
Szabolcs Nagy
szabolcs.nagy@arm.com
Wed May 20 10:27:37 GMT 2020
The 05/18/2020 17:28, Florian Weimer wrote:
> * Szabolcs Nagy:
>
> > +/* Note: Custom type is used as ElfW(Nhdr) is wrong on 64 bit targets. */
>
> Are you sure about that?
>
> typedef struct
> {
> Elf32_Word n_namesz; /* Length of the note's name. */
> Elf32_Word n_descsz; /* Length of the note's descriptor. */
> Elf32_Word n_type; /* Type of the note. */
> } Elf32_Nhdr;
>
> typedef struct
> {
> Elf64_Word n_namesz; /* Length of the note's name. */
> Elf64_Word n_descsz; /* Length of the note's descriptor. */
> Elf64_Word n_type; /* Type of the note. */
> } Elf64_Nhdr;
>
> The types are the same:
>
> typedef uint32_t Elf32_Word;
> typedef uint32_t Elf64_Word;
>
> I admit this is super-confusing.
aah i missed this, then the struct can be
#include <elf.h>
__attribute__ ((used, aligned (4), section (".note.ABI-tag")))
static const struct
{
ElfW(Nhdr) nhdr;
char name[4];
int32_t desc[4];
} __abi_tag = {
{ .n_namesz = 4, .n_descsz = 16, .n_type = 1 },
"GNU",
{ __ABI_TAG_OS, __ABI_TAG_VERSION }
};
i think the aligned attribute is still needed in case on
some target uint32_t has smaller alignemnt than 4.
i can change this if it is considered to be better
or just remove the incorrect comment.
More information about the Libc-alpha
mailing list