}
else
{
+ bfd_byte *contents;
+
if (rel.r_offset >= sec->size)
abort ();
+
+ if (elf_section_data (sec)->this_hdr.contents
+ != NULL)
+ contents
+ = elf_section_data (sec)->this_hdr.contents;
+ else
+ {
+ if (!bfd_malloc_and_get_section (sec->owner,
+ sec,
+ &contents))
+ info->callbacks->einfo
+ /* xgettext:c-format */
+ (_("%F%P: %pB: failed to allocate memory for section `%pA'\n"),
+ info->output_bfd, sec);
+
+ /* Cache the section contents for
+ elf_link_input_bfd. */
+ elf_section_data (sec)->this_hdr.contents
+ = contents;
+ }
htab->elf_write_addend
(info->output_bfd, outrel->r_addend,
- (elf_section_data (sec)->this_hdr.contents
- + rel.r_offset));
+ contents + rel.r_offset);
}
}
}
--- /dev/null
+#source: dt-relr-2.s
+#ld: -e _start -pie --no-keep-memory $DT_RELR_LDFLAGS
+#readelf: -rW -d
+#target: [supports_dt_relr]
+
+#...
+ 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+
+ 0x[0-9a-f]+ \(RELRSZ\) +(8|16) \(bytes\)
+ 0x[0-9a-f]+ \(RELRENT\) +(4|8) \(bytes\)
+#...
+Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+ contains 1 entry:
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_(RELATIVE|UADDR.*) .*
+#...
+Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries:
+ 4 offsets
+#pass