return;
}
- const Output_data* first;
- if (this->output_data_.empty())
- first = this->output_bss_.front();
- else
- first = this->output_data_.front();
+ // Find the first and last section by address. The sections may
+ // have been sorted for the PT_LOAD segment.
+ const Output_data* first = NULL;
+ const Output_data* last_data = NULL;
+ const Output_data* last_bss = NULL;
+ this->find_first_and_last_list(&this->output_data_, &first, &last_data);
+ this->find_first_and_last_list(&this->output_bss_, &first, &last_bss);
+
this->vaddr_ = first->address();
this->paddr_ = (first->has_load_address()
? first->load_address()
if (this->output_data_.empty())
this->filesz_ = 0;
else
- {
- const Output_data* last_data = this->output_data_.back();
- this->filesz_ = (last_data->address()
- + last_data->data_size()
- - this->vaddr_);
- }
+ this->filesz_ = (last_data->address()
+ + last_data->data_size()
+ - this->vaddr_);
- const Output_data* last;
- if (this->output_bss_.empty())
- last = this->output_data_.back();
- else
- last = this->output_bss_.back();
+ const Output_data* last = last_bss != NULL ? last_bss : last_data;
this->memsz_ = (last->address()
+ last->data_size()
- this->vaddr_);
}
}
+// Look through a list of Output_data objects and find the first and
+// last by address.
+
+void
+Output_segment::find_first_and_last_list(const Output_data_list* pdl,
+ const Output_data** pfirst,
+ const Output_data** plast) const
+{
+ const Output_data* first = *pfirst;
+ const Output_data* last = *plast;
+ for (Output_data_list::const_iterator p = pdl->begin(); p != pdl->end(); ++p)
+ {
+ if (first == NULL
+ || (*p)->address() < first->address()
+ || ((*p)->address() == first->address()
+ && (*p)->data_size() < first->data_size()))
+ {
+ first = *p;
+ *pfirst = first;
+ }
+ if (last == NULL
+ || (*p)->address() > last->address()
+ || ((*p)->address() == last->address()
+ && (*p)->data_size() > last->data_size()))
+ {
+ last = *p;
+ *plast = last;
+ }
+ }
+}
+
// Set the TLS offsets of the sections in the PT_TLS segment.
void
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6 ver_test_8 ver_test_9 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_11 protected_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2 relro_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_strip_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_script_test script_test_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2 justsyms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test script_test_3 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_strip_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_script_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) \
relro_script_test_OBJECTS = $(am_relro_script_test_OBJECTS)
relro_script_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(relro_script_test_LDFLAGS) $(LDFLAGS) -o $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_relro_strip_test_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test_main.$(OBJEXT)
+relro_strip_test_OBJECTS = $(am_relro_strip_test_OBJECTS)
+relro_strip_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
+ $(relro_strip_test_LDFLAGS) $(LDFLAGS) -o $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_relro_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test_main.$(OBJEXT)
relro_test_OBJECTS = $(am_relro_test_OBJECTS)
plugin_test_2.c plugin_test_3.c plugin_test_4.c \
plugin_test_5.c plugin_test_6.c plugin_test_7.c \
plugin_test_8.c $(protected_1_SOURCES) $(protected_2_SOURCES) \
- $(relro_script_test_SOURCES) $(relro_test_SOURCES) \
- $(script_test_1_SOURCES) $(script_test_2_SOURCES) \
- script_test_3.c $(searched_file_test_SOURCES) \
- $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \
+ $(relro_script_test_SOURCES) $(relro_strip_test_SOURCES) \
+ $(relro_test_SOURCES) $(script_test_1_SOURCES) \
+ $(script_test_2_SOURCES) script_test_3.c \
+ $(searched_file_test_SOURCES) $(thin_archive_test_1_SOURCES) \
+ $(thin_archive_test_2_SOURCES) \
$(tls_phdrs_script_test_SOURCES) $(tls_pic_test_SOURCES) \
tls_pie_pic_test.c tls_pie_test.c $(tls_script_test_SOURCES) \
$(tls_shared_gd_to_ie_test_SOURCES) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_test_DEPENDENCIES = gcctestdir/ld relro_test.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_test_LDADD = relro_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_strip_test_SOURCES = relro_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_strip_test_DEPENDENCIES = gcctestdir/ld relro_strip_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_strip_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_strip_test_LDADD = relro_strip_test.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_script_test_SOURCES = relro_test_main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_script_test_DEPENDENCIES = gcctestdir/ld relro_script_test.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_script_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
relro_script_test$(EXEEXT): $(relro_script_test_OBJECTS) $(relro_script_test_DEPENDENCIES)
@rm -f relro_script_test$(EXEEXT)
$(relro_script_test_LINK) $(relro_script_test_OBJECTS) $(relro_script_test_LDADD) $(LIBS)
+relro_strip_test$(EXEEXT): $(relro_strip_test_OBJECTS) $(relro_strip_test_DEPENDENCIES)
+ @rm -f relro_strip_test$(EXEEXT)
+ $(relro_strip_test_LINK) $(relro_strip_test_OBJECTS) $(relro_strip_test_LDADD) $(LIBS)
relro_test$(EXEEXT): $(relro_test_OBJECTS) $(relro_test_DEPENDENCIES)
@rm -f relro_test$(EXEEXT)
$(relro_test_LINK) $(relro_test_OBJECTS) $(relro_test_LDADD) $(LIBS)
@p='protected_2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
relro_test.log: relro_test$(EXEEXT)
@p='relro_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+relro_strip_test.log: relro_strip_test$(EXEEXT)
+ @p='relro_strip_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
relro_script_test.log: relro_script_test$(EXEEXT)
@p='relro_script_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
script_test_1.log: script_test_1$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro relro_test_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_test_pic.o: relro_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_strip_test.so: relro_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_STRIP) -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@relro_script_test.so: gcctestdir/ld relro_script_test.t relro_test_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,-z,relro -T $(srcdir)/relro_script_test.t relro_test_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2.o: justsyms_2.cc