bug-binutils
[Top][All Lists]
Advanced

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

[Bug gold/13850] New: init_array/fini_array sections are not in PT_GNU_R


From: petechou at gmail dot com
Subject: [Bug gold/13850] New: init_array/fini_array sections are not in PT_GNU_RELRO as -z relro is given
Date: Thu, 15 Mar 2012 09:55:48 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=13850

             Bug #: 13850
           Summary: init_array/fini_array sections are not in PT_GNU_RELRO
                    as -z relro is given
           Product: binutils
           Version: 2.23 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gold
        AssignedTo: address@hidden
        ReportedBy: address@hidden
                CC: address@hidden
    Classification: Unclassified


Hi,



Recently I'm studying RELRO and find that compared to gnu ld, gold produces a
different result (e.g., .init_array section did not go into PT_GNU_RELRO as
linking with -z relro).



In the following diff, please find the condition, "&& type ==
elfcpp::SHT_PROGBITS", that causes the different behavior.



Looks like this condition is not necessary (or should be moved into an inner
"if").



Any comment?



diff --git a/gold/layout.cc b/gold/layout.cc

index a4ef31a..13f7ea1 100644

--- a/gold/layout.cc

+++ b/gold/layout.cc

@@ -1368,29 +1368,28 @@ Layout::make_output_section(const char* name,
elfcpp::Elf_Word type,

          else if (is_prefix_of(".fini_array", name))

            type = elfcpp::SHT_FINI_ARRAY;

        }



       // FIXME: const_cast is ugly.

       Target* target = const_cast<Target*>(&parameters->target());

       os = target->make_output_section(name, type, flags);

     }



   // With -z relro, we have to recognize the special sections by name.

   // There is no other way.

   bool is_relro_local = false;

   if (!this->script_options_->saw_sections_clause()

       && parameters->options().relro()

-      && type == elfcpp::SHT_PROGBITS

       && (flags & elfcpp::SHF_ALLOC) != 0

       && (flags & elfcpp::SHF_WRITE) != 0)

     {

       if (strcmp(name, ".data.rel.ro") == 0)

        is_relro = true;

       else if (strcmp(name, ".data.rel.ro.local") == 0)

        {

          is_relro = true;

          is_relro_local = true;

        }

       else if (type == elfcpp::SHT_INIT_ARRAY

               || type == elfcpp::SHT_FINI_ARRAY

               || type == elfcpp::SHT_PREINIT_ARRAY)

        is_relro = true;



-

Thanks,

Pete

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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]