bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/22136] Support marking "debug" info files with special ET_


From: hjl.tools at gmail dot com
Subject: [Bug binutils/22136] Support marking "debug" info files with special ET_GNU_DEBUG_* values.
Date: Fri, 15 Sep 2017 17:28:44 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22136

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Nick Clifton from comment #6)
> Hi H.J.
> 
> > Why not use program property?
> 
> I can see a couple of potential objections:
> 
>   * Separate debug info files do not (currently) contain any notes.

Of cause, update will be needed.  To generate a property, I use

     /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and
         GNU_PROPERTY_X86_FEATURE_1_SHSTK.  */
      prop = _bfd_elf_get_property (ebfd,
                                    GNU_PROPERTY_X86_FEATURE_1_AND,
                                    4);
      prop->u.number |= features;
      prop->pr_kind = property_number;

      /* Create the GNU property note section if needed.  */
      if (pbfd == NULL)
        {
          sec = bfd_make_section_with_flags (ebfd,
                                             NOTE_GNU_PROPERTY_SECTION_NAME,
                                             (SEC_ALLOC
                                              | SEC_LOAD
                                              | SEC_IN_MEMORY
                                              | SEC_READONLY
                                              | SEC_HAS_CONTENTS
                                              | SEC_DATA));
          if (sec == NULL)
            info->callbacks->einfo (_("%F: failed to create GNU property
section\n"));

          if (!bfd_set_section_alignment (ebfd, sec, class_align))
            {
error_alignment:
              info->callbacks->einfo (_("%F%A: failed to align section\n"),
                                      sec);
            }

          elf_section_type (sec) = SHT_NOTE;
        }

>   * It is harder for a tool to locate and parse the notes section
>     than to just examine the e_type field in the ELF header.  Since
>     the point of this change is to allow ELF consumers to detect
>     non-ELF-conforming separate debug info files, allowing them to do
>     so easily would be a good idea.

ELF consumers may already parse PT_NOTE segment.  It isn't that hard to
extend it to cover NT_GNU_PROPERTY_TYPE_0.

>   * The GNU Property Notes are currently only supported on x86 targets.

That is not true.  All ELF targets support:

/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0).  */
#define GNU_PROPERTY_STACK_SIZE                 1
#define GNU_PROPERTY_NO_COPY_ON_PROTECTED       2

address@hidden binutils]$ ../gas/as-new -o x.o
/export/gnu/import/git/sources/binutils-gdb/binutils/testsuite/binutils-all/i386/pr21231a.s
address@hidden binutils]$ ./readelf -n x.o

Displaying notes found in: .note.gnu.property
  Owner                 Data size       Description
  GNU                  0x00000008       NT_GNU_PROPERTY_TYPE_0
      Properties: no copy on protected 
address@hidden binutils]$ file x.o
x.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
address@hidden binutils]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]