• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision5522f910cb539905d6adfdceab208ddfa5e84557 (tree)
Zeit2016-04-29 17:24:42
AutorNick Clifton <nickc@redh...>
CommiterNick Clifton

Log Message

Enhance support for copying and stripping Solaris and ARM binaries.

PR 19938
bfd * elf-bfd.h (struct elf_backend_data): Rename
elf_backend_set_special_section_info_and_link to
elf_backend_copy_special_section_fields.
* elfxx-target.h: Likewise.
* elf.c (section_match): Ignore the SHF_INFO_LINK flag when
comparing section flags.
(copy_special_section_fields): New function.
(_bfd_elf_copy_private_bfd_data): Copy the EI_ABIVERSION field.
Perform two scans over special sections. The first one looks for
a direct mapping between the output section and an input section.
The second scan looks for a possible match based upon section
characteristics.
* elf32-arm.c (elf32_arm_copy_special_section_fields): New
function. Handle setting the sh_link field of SHT_ARM_EXIDX
sections.
* elf32-i386.c (elf32_i386_set_special_info_link): Rename to
elf32_i386_copy_solaris_special_section_fields.
* elf32-sparc.c (elf32_sparc_set_special_section_info_link):
Rename to elf32_sparc_copy_solaris_special_section_fields.
* elf64-x86-64.c (elf64_x86_64_set_special_info_link): Rename to
elf64_x86_64_copy_solaris_special_section_fields.

binutils* readelf.c (get_solaris_segment_type): New function.
(get_segment_type): Call it.

Ändern Zusammenfassung

Diff

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,28 @@
1+2016-04-29 Nick Clifton <nickc@redhat.com>
2+
3+ PR 19938
4+ * elf-bfd.h (struct elf_backend_data): Rename
5+ elf_backend_set_special_section_info_and_link to
6+ elf_backend_copy_special_section_fields.
7+ * elfxx-target.h: Likewise.
8+ * elf.c (section_match): Ignore the SHF_INFO_LINK flag when
9+ comparing section flags.
10+ (copy_special_section_fields): New function.
11+ (_bfd_elf_copy_private_bfd_data): Copy the EI_ABIVERSION field.
12+ Perform two scans over special sections. The first one looks for
13+ a direct mapping between the output section and an input section.
14+ The second scan looks for a possible match based upon section
15+ characteristics.
16+ * elf32-arm.c (elf32_arm_copy_special_section_fields): New
17+ function. Handle setting the sh_link field of SHT_ARM_EXIDX
18+ sections.
19+ * elf32-i386.c (elf32_i386_set_special_info_link): Rename to
20+ elf32_i386_copy_solaris_special_section_fields.
21+ * elf32-sparc.c (elf32_sparc_set_special_section_info_link):
22+ Rename to elf32_sparc_copy_solaris_special_section_fields.
23+ * elf64-x86-64.c (elf64_x86_64_set_special_info_link): Rename to
24+ elf64_x86_64_copy_solaris_special_section_fields.
25+
126 2016-04-28 Nick Clifton <nickc@redhat.com>
227
328 * po/zh_CN.po: Updated Chinese (simplified) translation.
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1300,13 +1300,15 @@ struct elf_backend_data
13001300 /* Return the section which RELOC_SEC applies to. */
13011301 asection *(*get_reloc_section) (asection *reloc_sec);
13021302
1303- /* Called when setting the sh_link and sh_info fields of a section with a
1304- type >= SHT_LOOS. Returns TRUE if these fields were initialised in
1305- OHEADER, FALSE otherwise. IHEADER is the best guess matching section
1306- from the input bfd IBFD. */
1307- bfd_boolean (*elf_backend_set_special_section_info_and_link)
1308- (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *iheader,
1309- Elf_Internal_Shdr *oheader);
1303+ /* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
1304+ has a type >= SHT_LOOS. Returns TRUE if the fields were initialised,
1305+ FALSE otherwise. Can be called multiple times for a given section,
1306+ until it returns TRUE. Most of the times it is called ISECTION will be
1307+ set to an input section that might be associated with the output section.
1308+ The last time that it is called, ISECTION will be set to NULL. */
1309+ bfd_boolean (*elf_backend_copy_special_section_fields)
1310+ (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *isection,
1311+ Elf_Internal_Shdr *osection);
13101312
13111313 /* Used to handle bad SHF_LINK_ORDER input. */
13121314 bfd_error_handler_type link_order_error_handler;
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1218,11 +1218,13 @@ bfd_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
12181218 should be the same. */
12191219
12201220 static bfd_boolean
1221-section_match (Elf_Internal_Shdr * a, Elf_Internal_Shdr * b)
1221+section_match (const Elf_Internal_Shdr * a,
1222+ const Elf_Internal_Shdr * b)
12221223 {
12231224 return
12241225 a->sh_type == b->sh_type
1225- && a->sh_flags == b->sh_flags
1226+ && (a->sh_flags & ~ SHF_INFO_LINK)
1227+ == (b->sh_flags & ~ SHF_INFO_LINK)
12261228 && a->sh_addralign == b->sh_addralign
12271229 && a->sh_size == b->sh_size
12281230 && a->sh_entsize == b->sh_entsize
@@ -1236,7 +1238,7 @@ section_match (Elf_Internal_Shdr * a, Elf_Internal_Shdr * b)
12361238 to be the correct section. */
12371239
12381240 static unsigned int
1239-find_link (bfd * obfd, Elf_Internal_Shdr * iheader, unsigned int hint)
1241+find_link (const bfd * obfd, const Elf_Internal_Shdr * iheader, const unsigned int hint)
12401242 {
12411243 Elf_Internal_Shdr ** oheaders = elf_elfsections (obfd);
12421244 unsigned int i;
@@ -1257,14 +1259,110 @@ find_link (bfd * obfd, Elf_Internal_Shdr * iheader, unsigned int hint)
12571259 return SHN_UNDEF;
12581260 }
12591261
1262+/* PR 19938: Attempt to set the ELF section header fields of an OS or
1263+ Processor specific section, based upon a matching input section.
1264+ Returns TRUE upon success, FALSE otherwise. */
1265+
1266+static bfd_boolean
1267+copy_special_section_fields (const bfd *ibfd,
1268+ bfd *obfd,
1269+ const Elf_Internal_Shdr *iheader,
1270+ Elf_Internal_Shdr *oheader,
1271+ const unsigned int secnum)
1272+{
1273+ const struct elf_backend_data *bed = get_elf_backend_data (obfd);
1274+ const Elf_Internal_Shdr **iheaders = (const Elf_Internal_Shdr **) elf_elfsections (ibfd);
1275+ bfd_boolean changed = FALSE;
1276+ unsigned int sh_link;
1277+
1278+ if (oheader->sh_type == SHT_NOBITS)
1279+ {
1280+ /* This is a feature for objcopy --only-keep-debug:
1281+ When a section's type is changed to NOBITS, we preserve
1282+ the sh_link and sh_info fields so that they can be
1283+ matched up with the original.
1284+
1285+ Note: Strictly speaking these assignments are wrong.
1286+ The sh_link and sh_info fields should point to the
1287+ relevent sections in the output BFD, which may not be in
1288+ the same location as they were in the input BFD. But
1289+ the whole point of this action is to preserve the
1290+ original values of the sh_link and sh_info fields, so
1291+ that they can be matched up with the section headers in
1292+ the original file. So strictly speaking we may be
1293+ creating an invalid ELF file, but it is only for a file
1294+ that just contains debug info and only for sections
1295+ without any contents. */
1296+ if (oheader->sh_link == 0)
1297+ oheader->sh_link = iheader->sh_link;
1298+ if (oheader->sh_info == 0)
1299+ oheader->sh_info = iheader->sh_info;
1300+ return TRUE;
1301+ }
1302+
1303+ /* Allow the target a chance to decide how these fields should be set. */
1304+ if (bed->elf_backend_copy_special_section_fields != NULL
1305+ && bed->elf_backend_copy_special_section_fields
1306+ (ibfd, obfd, iheader, oheader))
1307+ return TRUE;
1308+
1309+ /* We have an iheader which might match oheader, and which has non-zero
1310+ sh_info and/or sh_link fields. Attempt to follow those links and find
1311+ the section in the output bfd which corresponds to the linked section
1312+ in the input bfd. */
1313+ if (iheader->sh_link != SHN_UNDEF)
1314+ {
1315+ sh_link = find_link (obfd, iheaders[iheader->sh_link], iheader->sh_link);
1316+ if (sh_link != SHN_UNDEF)
1317+ {
1318+ oheader->sh_link = sh_link;
1319+ changed = TRUE;
1320+ }
1321+ else
1322+ /* FIXME: Should we install iheader->sh_link
1323+ if we could not find a match ? */
1324+ (* _bfd_error_handler)
1325+ (_("%B: Failed to find link section for section %d"), obfd, secnum);
1326+ }
1327+
1328+ if (iheader->sh_info)
1329+ {
1330+ /* The sh_info field can hold arbitrary information, but if the
1331+ SHF_LINK_INFO flag is set then it should be interpreted as a
1332+ section index. */
1333+ if (iheader->sh_flags & SHF_INFO_LINK)
1334+ {
1335+ sh_link = find_link (obfd, iheaders[iheader->sh_info],
1336+ iheader->sh_info);
1337+ if (sh_link != SHN_UNDEF)
1338+ oheader->sh_flags |= SHF_INFO_LINK;
1339+ }
1340+ else
1341+ /* No idea what it means - just copy it. */
1342+ sh_link = iheader->sh_info;
1343+
1344+ if (sh_link != SHN_UNDEF)
1345+ {
1346+ oheader->sh_info = sh_link;
1347+ changed = TRUE;
1348+ }
1349+ else
1350+ (* _bfd_error_handler)
1351+ (_("%B: Failed to find info section for section %d"), obfd, secnum);
1352+ }
1353+
1354+ return changed;
1355+}
1356+
12601357 /* Copy the program header and other data from one object module to
12611358 another. */
12621359
12631360 bfd_boolean
12641361 _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
12651362 {
1266- Elf_Internal_Shdr ** iheaders = elf_elfsections (ibfd);
1267- Elf_Internal_Shdr ** oheaders = elf_elfsections (obfd);
1363+ const Elf_Internal_Shdr **iheaders = (const Elf_Internal_Shdr **) elf_elfsections (ibfd);
1364+ Elf_Internal_Shdr **oheaders = elf_elfsections (obfd);
1365+ const struct elf_backend_data *bed;
12681366 unsigned int i;
12691367
12701368 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
@@ -1283,39 +1381,84 @@ _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
12831381 elf_elfheader (obfd)->e_ident[EI_OSABI] =
12841382 elf_elfheader (ibfd)->e_ident[EI_OSABI];
12851383
1384+ /* If set, copy the EI_ABIVERSION field. */
1385+ if (elf_elfheader (ibfd)->e_ident[EI_ABIVERSION])
1386+ elf_elfheader (obfd)->e_ident[EI_ABIVERSION]
1387+ = elf_elfheader (ibfd)->e_ident[EI_ABIVERSION];
1388+
12861389 /* Copy object attributes. */
12871390 _bfd_elf_copy_obj_attributes (ibfd, obfd);
12881391
12891392 if (iheaders == NULL || oheaders == NULL)
12901393 return TRUE;
12911394
1292- /* Possibly copy the sh_info and sh_link fields. */
1395+ bed = get_elf_backend_data (obfd);
1396+
1397+ /* Possibly copy other fields in the section header. */
12931398 for (i = 1; i < elf_numsections (obfd); i++)
12941399 {
12951400 unsigned int j;
12961401 Elf_Internal_Shdr * oheader = oheaders[i];
12971402
1403+ /* Ignore ordinary sections. SHT_NOBITS sections are considered however
1404+ because of a special case need for generating separate debug info
1405+ files. See below for more details. */
12981406 if (oheader == NULL
12991407 || (oheader->sh_type != SHT_NOBITS
1300- && oheader->sh_type < SHT_LOOS)
1301- || oheader->sh_size == 0
1408+ && oheader->sh_type < SHT_LOOS))
1409+ continue;
1410+
1411+ /* Ignore empty sections, and sections whose
1412+ fields have already been initialised. */
1413+ if (oheader->sh_size == 0
13021414 || (oheader->sh_info != 0 && oheader->sh_link != 0))
13031415 continue;
13041416
13051417 /* Scan for the matching section in the input bfd.
1306- FIXME: We could use something better than a linear scan here.
1418+ First we try for a direct mapping between the input and output sections. */
1419+ for (j = 1; j < elf_numsections (ibfd); j++)
1420+ {
1421+ const Elf_Internal_Shdr * iheader = iheaders[j];
1422+
1423+ if (iheader == NULL)
1424+ continue;
1425+
1426+ if (oheader->bfd_section != NULL
1427+ && iheader->bfd_section != NULL
1428+ && iheader->bfd_section->output_section != NULL
1429+ && iheader->bfd_section->output_section == oheader->bfd_section)
1430+ {
1431+ /* We have found a connection from the input section to the
1432+ output section. Attempt to copy the header fields. If
1433+ this fails then do not try any further sections - there
1434+ should only be a one-to-one mapping between input and output. */
1435+ if (! copy_special_section_fields (ibfd, obfd, iheader, oheader, i))
1436+ j = elf_numsections (ibfd);
1437+ break;
1438+ }
1439+ }
1440+
1441+ if (j < elf_numsections (ibfd))
1442+ continue;
1443+
1444+ /* That failed. So try to deduce the corresponding input section.
13071445 Unfortunately we cannot compare names as the output string table
13081446 is empty, so instead we check size, address and type. */
13091447 for (j = 1; j < elf_numsections (ibfd); j++)
13101448 {
1311- Elf_Internal_Shdr * iheader = iheaders[j];
1449+ const Elf_Internal_Shdr * iheader = iheaders[j];
1450+
1451+ if (iheader == NULL)
1452+ continue;
13121453
1313- /* Since --only-keep-debug turns all non-debug sections into
1454+ /* Try matching fields in the input section's header.
1455+ Since --only-keep-debug turns all non-debug sections into
13141456 SHT_NOBITS sections, the output SHT_NOBITS type matches any
13151457 input type. */
13161458 if ((oheader->sh_type == SHT_NOBITS
13171459 || iheader->sh_type == oheader->sh_type)
1318- && iheader->sh_flags == oheader->sh_flags
1460+ && (iheader->sh_flags & ~ SHF_INFO_LINK)
1461+ == (oheader->sh_flags & ~ SHF_INFO_LINK)
13191462 && iheader->sh_addralign == oheader->sh_addralign
13201463 && iheader->sh_entsize == oheader->sh_entsize
13211464 && iheader->sh_size == oheader->sh_size
@@ -1323,99 +1466,18 @@ _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
13231466 && (iheader->sh_info != oheader->sh_info
13241467 || iheader->sh_link != oheader->sh_link))
13251468 {
1326- /* PR 19938: Attempt to preserve the sh_link and sh_info fields
1327- of OS and Processor specific sections. We try harder for
1328- these sections, because this is not just about matching
1329- stripped binaries to their originals. */
1330- if (oheader->sh_type >= SHT_LOOS)
1331- {
1332- const struct elf_backend_data *bed = get_elf_backend_data (obfd);
1333- bfd_boolean changed = FALSE;
1334- unsigned int sh_link;
1335-
1336- /* Allow the target a chance to decide how these fields should
1337- be set. */
1338- if (bed->elf_backend_set_special_section_info_and_link != NULL
1339- && bed->elf_backend_set_special_section_info_and_link
1340- (ibfd, obfd, iheader, oheader))
1341- break;
1342-
1343- /* We have iheader which matches oheader, but which has
1344- non-zero sh_info and/or sh_link fields. Attempt to
1345- follow those links and find the section in the output
1346- bfd which corresponds to the linked section in the input
1347- bfd. */
1348- if (iheader->sh_link != SHN_UNDEF)
1349- {
1350- sh_link = find_link (obfd,
1351- iheaders[iheader->sh_link],
1352- iheader->sh_link);
1353- if (sh_link != SHN_UNDEF)
1354- {
1355- oheader->sh_link = sh_link;
1356- changed = TRUE;
1357- }
1358- else
1359- /* FIXME: Should we install iheader->sh_link
1360- if we could not find a match ? */
1361- (* _bfd_error_handler)
1362- (_("%B: Failed to find link section for section %d"),
1363- obfd, i);
1364- }
1365-
1366- if (iheader->sh_info)
1367- {
1368- /* The sh_info field can hold arbitrary information,
1369- but if the SHF_LINK_INFO flag is set then it
1370- should be interpreted as a section index. */
1371- if (iheader->sh_flags & SHF_INFO_LINK)
1372- sh_link = find_link (obfd,
1373- iheaders[iheader->sh_info],
1374- iheader->sh_info);
1375- else
1376- /* No idea what it means - just copy it. */
1377- sh_link = iheader->sh_info;
1378-
1379- if (sh_link != SHN_UNDEF)
1380- {
1381- oheader->sh_info = sh_link;
1382- changed = TRUE;
1383- }
1384- else
1385- (* _bfd_error_handler)
1386- (_("%B: Failed to find info section for section %d"),
1387- obfd, i);
1388- }
1389-
1390- if (changed)
1391- break;
1392- }
1393- else
1394- {
1395- /* This is an feature for objcopy --only-keep-debug:
1396- When a section's type is changed to NOBITS, we preserve
1397- the sh_link and sh_info fields so that they can be
1398- matched up with the original.
1399-
1400- Note: Strictly speaking these assignments are wrong.
1401- The sh_link and sh_info fields should point to the
1402- relevent sections in the output BFD, which may not be in
1403- the same location as they were in the input BFD. But
1404- the whole point of this action is to preserve the
1405- original values of the sh_link and sh_info fields, so
1406- that they can be matched up with the section headers in
1407- the original file. So strictly speaking we may be
1408- creating an invalid ELF file, but it is only for a file
1409- that just contains debug info and only for sections
1410- without any contents. */
1411- if (oheader->sh_link == 0)
1412- oheader->sh_link = iheader->sh_link;
1413- if (oheader->sh_info == 0)
1414- oheader->sh_info = iheader->sh_info;
1415- break;
1416- }
1469+ if (copy_special_section_fields (ibfd, obfd, iheader, oheader, i))
1470+ break;
14171471 }
14181472 }
1473+
1474+ if (j == elf_numsections (ibfd) && oheader->sh_type >= SHT_LOOS)
1475+ {
1476+ /* Final attempt. Call the backend copy function
1477+ with a NULL input section. */
1478+ if (bed->elf_backend_copy_special_section_fields != NULL)
1479+ bed->elf_backend_copy_special_section_fields (ibfd, obfd, NULL, oheader);
1480+ }
14191481 }
14201482
14211483 return TRUE;
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -14112,11 +14112,15 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
1411214112 s = bfd_get_linker_section (dynobj, ".dynbss");
1411314113 BFD_ASSERT (s != NULL);
1411414114
14115- /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
14116- copy the initial value out of the dynamic object and into the
14117- runtime process image. We need to remember the offset into the
14115+ /* If allowed, we must generate a R_ARM_COPY reloc to tell the dynamic
14116+ linker to copy the initial value out of the dynamic object and into
14117+ the runtime process image. We need to remember the offset into the
1411814118 .rel(a).bss section we are going to use. */
14119- if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
14119+ if (info->nocopyreloc == 0
14120+ && (h->root.u.def.section->flags & SEC_ALLOC) != 0
14121+ /* PR 16177: A copy is only needed if the input section is readonly. */
14122+ && (h->root.u.def.section->flags & SEC_READONLY) == 0
14123+ && h->size != 0)
1412014124 {
1412114125 asection *srel;
1412214126
@@ -17873,6 +17877,100 @@ elf32_arm_count_additional_relocs (asection *sec)
1787317877 return arm_data->additional_reloc_count;
1787417878 }
1787517879
17880+/* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
17881+ has a type >= SHT_LOOS. Returns TRUE if these fields were initialised
17882+ FALSE otherwise. ISECTION is the best guess matching section from the
17883+ input bfd IBFD, but it might be NULL. */
17884+
17885+static bfd_boolean
17886+elf32_arm_copy_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
17887+ bfd *obfd ATTRIBUTE_UNUSED,
17888+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
17889+ Elf_Internal_Shdr *osection)
17890+{
17891+ switch (osection->sh_type)
17892+ {
17893+ case SHT_ARM_EXIDX:
17894+ {
17895+ Elf_Internal_Shdr **oheaders = elf_elfsections (obfd);
17896+ Elf_Internal_Shdr **iheaders = elf_elfsections (ibfd);
17897+ unsigned i = 0;
17898+
17899+ osection->sh_flags = SHF_ALLOC | SHF_LINK_ORDER;
17900+ osection->sh_info = 0;
17901+
17902+ /* The sh_link field must be set to the text section associated with
17903+ this index section. Unfortunately the ARM EHABI does not specify
17904+ exactly how to determine this association. Our caller does try
17905+ to match up OSECTION with its corresponding input section however
17906+ so that is a good first guess. */
17907+ if (isection != NULL
17908+ && osection->bfd_section != NULL
17909+ && isection->bfd_section != NULL
17910+ && isection->bfd_section->output_section != NULL
17911+ && isection->bfd_section->output_section == osection->bfd_section
17912+ && iheaders != NULL
17913+ && isection->sh_link > 0
17914+ && isection->sh_link < elf_numsections (ibfd)
17915+ && iheaders[isection->sh_link]->bfd_section != NULL
17916+ && iheaders[isection->sh_link]->bfd_section->output_section != NULL
17917+ )
17918+ {
17919+ for (i = elf_numsections (obfd); i-- > 0;)
17920+ if (oheaders[i]->bfd_section
17921+ == iheaders[isection->sh_link]->bfd_section->output_section)
17922+ break;
17923+ }
17924+
17925+ if (i == 0)
17926+ {
17927+ /* Failing that we have to find a matching section ourselves. If
17928+ we had the output section name available we could compare that
17929+ with input section names. Unfortunately we don't. So instead
17930+ we use a simple heuristic and look for the nearest executable
17931+ section before this one. */
17932+ for (i = elf_numsections (obfd); i-- > 0;)
17933+ if (oheaders[i] == osection)
17934+ break;
17935+ if (i == 0)
17936+ break;
17937+
17938+ while (i-- > 0)
17939+ if (oheaders[i]->sh_type == SHT_PROGBITS
17940+ && (oheaders[i]->sh_flags & (SHF_ALLOC | SHF_EXECINSTR))
17941+ == (SHF_ALLOC | SHF_EXECINSTR))
17942+ break;
17943+ }
17944+
17945+ if (i)
17946+ {
17947+ osection->sh_link = i;
17948+ /* If the text section was part of a group
17949+ then the index section should be too. */
17950+ if (oheaders[i]->sh_flags & SHF_GROUP)
17951+ osection->sh_flags |= SHF_GROUP;
17952+ return TRUE;
17953+ }
17954+ }
17955+ break;
17956+
17957+ case SHT_ARM_PREEMPTMAP:
17958+ osection->sh_flags = SHF_ALLOC;
17959+ break;
17960+
17961+ case SHT_ARM_ATTRIBUTES:
17962+ case SHT_ARM_DEBUGOVERLAY:
17963+ case SHT_ARM_OVERLAYSECTION:
17964+ default:
17965+ break;
17966+ }
17967+
17968+ return FALSE;
17969+}
17970+
17971+#undef elf_backend_copy_special_section_fields
17972+#define elf_backend_copy_special_section_fields elf32_arm_copy_special_section_fields
17973+
1787617974 #define ELF_ARCH bfd_arch_arm
1787717975 #define ELF_TARGET_ID ARM_ELF_DATA
1787817976 #define ELF_MACHINE_CODE EM_ARM
@@ -18035,6 +18133,7 @@ elf32_arm_nacl_plt_sym_val (bfd_vma i, const asection *plt,
1803518133 #undef bfd_elf32_get_synthetic_symtab
1803618134 #undef elf_backend_plt_sym_val
1803718135 #define elf_backend_plt_sym_val elf32_arm_nacl_plt_sym_val
18136+#undef elf_backend_copy_special_section_fields
1803818137
1803918138 #undef ELF_MINPAGESIZE
1804018139 #undef ELF_COMMONPAGESIZE
@@ -18454,7 +18553,6 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt,
1845418553 return plt->vma + 4 * ARRAY_SIZE (elf32_arm_symbian_plt_entry) * i;
1845518554 }
1845618555
18457-
1845818556 #undef elf32_bed
1845918557 #define elf32_bed elf32_arm_symbian_bed
1846018558
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -5905,16 +5905,22 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
59055905 #undef elf_backend_strtab_flags
59065906 #define elf_backend_strtab_flags SHF_STRINGS
59075907
5908+/* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
5909+ has a type >= SHT_LOOS. Returns TRUE if these fields were initialised
5910+ FALSE otherwise. ISECTION is the best guess matching section from the
5911+ input bfd IBFD, but it might be NULL. */
5912+
59085913 static bfd_boolean
5909-elf32_i386_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
5910- bfd *obfd ATTRIBUTE_UNUSED,
5911- const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
5912- Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
5914+elf32_i386_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
5915+ bfd *obfd ATTRIBUTE_UNUSED,
5916+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
5917+ Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
59135918 {
59145919 /* PR 19938: FIXME: Need to add code for setting the sh_info
5915- and sh_link fields of Solaris specific section types.
5920+ and sh_link fields of Solaris specific section types. */
5921+ return FALSE;
59165922
5917- Based upon Oracle Solaris 11.3 Linkers and Libraries Guide, Ch. 13,
5923+ /* Based upon Oracle Solaris 11.3 Linkers and Libraries Guide, Ch. 13,
59185924 Object File Format, Table 13-9 ELF sh_link and sh_info Interpretation:
59195925
59205926 http://docs.oracle.com/cd/E53394_01/html/E54813/chapter6-94076.html#scrolltoc
@@ -5974,11 +5980,10 @@ SHT_SUNW_verneed The section header index of The number of version
59745980
59755981 SHT_SUNW_versym The section header index of 0
59765982 [0x6fffffff] the associated symbol table. */
5977- return FALSE;
59785983 }
59795984
5980-#undef elf_backend_set_special_section_info_and_link
5981-#define elf_backend_set_special_section_info_and_link elf32_i386_set_special_info_link
5985+#undef elf_backend_copy_special_section_fields
5986+#define elf_backend_copy_special_section_fields elf32_i386_copy_solaris_special_section_fields
59825987
59835988 #include "elf32-target.h"
59845989
@@ -6016,7 +6021,7 @@ elf32_iamcu_elf_object_p (bfd *abfd)
60166021 #define elf_backend_want_plt_sym 0
60176022
60186023 #undef elf_backend_strtab_flags
6019-#undef elf_backend_set_special_section_info_and_link
6024+#undef elf_backend_copy_special_section_fields
60206025
60216026 #include "elf32-target.h"
60226027
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -265,18 +265,18 @@ elf32_sparc_add_symbol_hook (bfd * abfd,
265265 #define elf_backend_strtab_flags SHF_STRINGS
266266
267267 static bfd_boolean
268-elf32_sparc_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
269- bfd *obfd ATTRIBUTE_UNUSED,
270- const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
271- Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
268+elf32_sparc_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
269+ bfd *obfd ATTRIBUTE_UNUSED,
270+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
271+ Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
272272 {
273273 /* PR 19938: FIXME: Need to add code for setting the sh_info
274274 and sh_link fields of Solaris specific section types. */
275275 return FALSE;
276276 }
277277
278-#undef elf_backend_set_special_section_info_and_link
279-#define elf_backend_set_special_section_info_and_link elf32_sparc_set_special_info_link
278+#undef elf_backend_copy_special_section_fields
279+#define elf_backend_copy_special_section_fields elf32_sparc_copy_solaris_special_section_fields
280280
281281 #include "elf32-target.h"
282282
@@ -341,7 +341,7 @@ elf32_sparc_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
341341 elf32_sparc_vxworks_final_write_processing
342342 #undef elf_backend_static_tls_alignment
343343 #undef elf_backend_strtab_flags
344-#undef elf_backend_set_special_section_info_and_link
344+#undef elf_backend_copy_special_section_fields
345345
346346 #undef elf32_bed
347347 #define elf32_bed sparc_elf_vxworks_bed
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -6552,18 +6552,18 @@ static const struct bfd_elf_special_section
65526552 #define elf_backend_strtab_flags SHF_STRINGS
65536553
65546554 static bfd_boolean
6555-elf64_x86_64_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
6556- bfd *obfd ATTRIBUTE_UNUSED,
6557- const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
6558- Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
6555+elf64_x86_64_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
6556+ bfd *obfd ATTRIBUTE_UNUSED,
6557+ const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
6558+ Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
65596559 {
65606560 /* PR 19938: FIXME: Need to add code for setting the sh_info
65616561 and sh_link fields of Solaris specific section types. */
65626562 return FALSE;
65636563 }
65646564
6565-#undef elf_backend_set_special_section_info_and_link
6566-#define elf_backend_set_special_section_info_and_link elf64_x86_64_set_special_info_link
6565+#undef elf_backend_copy_special_section_fields
6566+#define elf_backend_copy_special_section_fields elf64_x86_64_copy_solaris_special_section_fields
65676567
65686568 #include "elf64-target.h"
65696569
@@ -6597,7 +6597,7 @@ elf64_x86_64_nacl_elf_object_p (bfd *abfd)
65976597 #undef elf_backend_want_plt_sym
65986598 #define elf_backend_want_plt_sym 0
65996599 #undef elf_backend_strtab_flags
6600-#undef elf_backend_set_special_section_info_and_link
6600+#undef elf_backend_copy_special_section_fields
66016601
66026602 /* NaCl uses substantially different PLT entries for the same effects. */
66036603
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -686,8 +686,8 @@
686686 #define elf_backend_get_reloc_section _bfd_elf_get_reloc_section
687687 #endif
688688
689-#ifndef elf_backend_set_special_section_info_and_link
690-#define elf_backend_set_special_section_info_and_link NULL
689+#ifndef elf_backend_copy_special_section_fields
690+#define elf_backend_copy_special_section_fields NULL
691691 #endif
692692
693693 #ifndef elf_backend_compact_eh_encoding
@@ -797,7 +797,7 @@ static struct elf_backend_data elfNN_bed =
797797 elf_backend_is_function_type,
798798 elf_backend_maybe_function_sym,
799799 elf_backend_get_reloc_section,
800- elf_backend_set_special_section_info_and_link,
800+ elf_backend_copy_special_section_fields,
801801 elf_backend_link_order_error_handler,
802802 elf_backend_relplt_name,
803803 ELF_MACHINE_ALT1,
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
1+2016-04-29 Nick Clifton <nickc@redhat.com>
2+
3+ PR 19938
4+ * readelf.c (get_solaris_segment_type): New function.
5+ (get_segment_type): Call it.
6+
17 2016-04-28 Nick Clifton <nickc@redhat.com>
28
39 * po/zh_CN.po: Updated Chinese (simplified) translation.
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -3689,6 +3689,23 @@ get_tic6x_segment_type (unsigned long type)
36893689 }
36903690
36913691 static const char *
3692+get_solaris_segment_type (unsigned long type)
3693+{
3694+ switch (type)
3695+ {
3696+ case 0x6464e550: return "PT_SUNW_UNWIND";
3697+ case 0x6474e550: return "PT_SUNW_EH_FRAME";
3698+ case 0x6ffffff7: return "PT_LOSUNW";
3699+ case 0x6ffffffa: return "PT_SUNWBSS";
3700+ case 0x6ffffffb: return "PT_SUNWSTACK";
3701+ case 0x6ffffffc: return "PT_SUNWDTRACE";
3702+ case 0x6ffffffd: return "PT_SUNWCAP";
3703+ case 0x6fffffff: return "PT_HISUNW";
3704+ default: return NULL;
3705+ }
3706+}
3707+
3708+static const char *
36923709 get_segment_type (unsigned long p_type)
36933710 {
36943711 static char buff[32];
@@ -3758,7 +3775,10 @@ get_segment_type (unsigned long p_type)
37583775 result = get_ia64_segment_type (p_type);
37593776 break;
37603777 default:
3761- result = NULL;
3778+ if (elf_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS)
3779+ result = get_solaris_segment_type (p_type);
3780+ else
3781+ result = NULL;
37623782 break;
37633783 }
37643784