simple-object-xcoff.c (simple_object_xcoff_find_sections): Search symbol table for .go_export symbol and apply pfn if found.
2017-06-07 Tony Reix <tony.reix@atos.net> Matthieu Sarter <matthieu.sarter.external@atos.net> David Edelsohn <dje.gcc@gmail.com> * simple-object-xcoff.c (simple_object_xcoff_find_sections): Search symbol table for .go_export symbol and apply pfn if found. Co-Authored-By: David Edelsohn <dje.gcc@gmail.com> Co-Authored-By: Matthieu Sarter <matthieu.sarter.external@atos.net> From-SVN: r248999
This commit is contained in:
parent
989cc652ee
commit
c1d2490437
|
@ -1,3 +1,10 @@
|
||||||
|
2017-06-07 Tony Reix <tony.reix@atos.net>
|
||||||
|
Matthieu Sarter <matthieu.sarter.external@atos.net>
|
||||||
|
David Edelsohn <dje.gcc@gmail.com>
|
||||||
|
|
||||||
|
* simple-object-xcoff.c (simple_object_xcoff_find_sections):
|
||||||
|
Search symbol table for .go_export symbol and apply pfn if found.
|
||||||
|
|
||||||
2017-05-31 DJ Delorie <dj@redhat.com>
|
2017-05-31 DJ Delorie <dj@redhat.com>
|
||||||
|
|
||||||
* configure.ac (strnlen): Add to AC_CHECK_DECLS.
|
* configure.ac (strnlen): Add to AC_CHECK_DECLS.
|
||||||
|
|
|
@ -258,6 +258,8 @@ union external_auxent
|
||||||
#define C_STAT (3)
|
#define C_STAT (3)
|
||||||
#define C_FILE (103)
|
#define C_FILE (103)
|
||||||
|
|
||||||
|
#define DBXMASK 0x80
|
||||||
|
|
||||||
/* Private data for an simple_object_read. */
|
/* Private data for an simple_object_read. */
|
||||||
|
|
||||||
struct simple_object_xcoff_read
|
struct simple_object_xcoff_read
|
||||||
|
@ -403,7 +405,9 @@ simple_object_xcoff_find_sections (simple_object_read *sobj,
|
||||||
unsigned int nscns;
|
unsigned int nscns;
|
||||||
char *strtab;
|
char *strtab;
|
||||||
size_t strtab_size;
|
size_t strtab_size;
|
||||||
|
struct external_syment *symtab = NULL;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
off_t textptr = 0;
|
||||||
|
|
||||||
scnhdr_size = u64 ? SCNHSZ64 : SCNHSZ32;
|
scnhdr_size = u64 ? SCNHSZ64 : SCNHSZ32;
|
||||||
scnbuf = XNEWVEC (unsigned char, scnhdr_size * ocr->nscns);
|
scnbuf = XNEWVEC (unsigned char, scnhdr_size * ocr->nscns);
|
||||||
|
@ -485,10 +489,118 @@ simple_object_xcoff_find_sections (simple_object_read *sobj,
|
||||||
u.xcoff32.s_size));
|
u.xcoff32.s_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp (name, ".text") == 0)
|
||||||
|
textptr = scnptr;
|
||||||
if (!(*pfn) (data, name, scnptr, size))
|
if (!(*pfn) (data, name, scnptr, size))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Special handling for .go_export CSECT. */
|
||||||
|
if (textptr != 0 && ocr->nsyms > 0)
|
||||||
|
{
|
||||||
|
unsigned char *sym, *aux;
|
||||||
|
const char *n_name;
|
||||||
|
unsigned long n_value, n_offset, n_zeroes, x_scnlen;
|
||||||
|
|
||||||
|
/* Read symbol table. */
|
||||||
|
symtab = XNEWVEC (struct external_syment, ocr->nsyms * SYMESZ);
|
||||||
|
if (!simple_object_internal_read (sobj->descriptor,
|
||||||
|
sobj->offset + ocr->symptr,
|
||||||
|
(unsigned char *)symtab,
|
||||||
|
ocr->nsyms * SYMESZ,
|
||||||
|
&errmsg, err))
|
||||||
|
{
|
||||||
|
XDELETEVEC (symtab);
|
||||||
|
XDELETEVEC (scnbuf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search in symbol table if we have a ".go_export" symbol. */
|
||||||
|
for (i = 0; i < ocr->nsyms; ++i)
|
||||||
|
{
|
||||||
|
sym = (unsigned char *)&symtab[i];
|
||||||
|
|
||||||
|
if (symtab[i].n_sclass[0] & DBXMASK)
|
||||||
|
{
|
||||||
|
/* Skip debug symbols whose names are in stabs. */
|
||||||
|
i += symtab[i].n_numaux[0];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (u64)
|
||||||
|
{
|
||||||
|
n_value = fetch_64 (sym + offsetof (struct external_syment,
|
||||||
|
u.xcoff64.n_value));
|
||||||
|
n_offset = fetch_32 (sym + offsetof (struct external_syment,
|
||||||
|
u.xcoff64.n_offset));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* ".go_export" is longer than N_SYMNMLEN */
|
||||||
|
n_zeroes = fetch_32 (sym + offsetof (struct external_syment,
|
||||||
|
u.xcoff32.n.n.n_zeroes));
|
||||||
|
if (n_zeroes != 0)
|
||||||
|
{
|
||||||
|
/* Skip auxiliary entries. */
|
||||||
|
i += symtab[i].n_numaux[0];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
n_value = fetch_32 (sym + offsetof (struct external_syment,
|
||||||
|
u.xcoff32.n_value));
|
||||||
|
n_offset = fetch_32 (sym + offsetof (struct external_syment,
|
||||||
|
u.xcoff32.n.n.n_offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The real section name is found in the string table. */
|
||||||
|
if (strtab == NULL)
|
||||||
|
{
|
||||||
|
strtab = simple_object_xcoff_read_strtab (sobj,
|
||||||
|
&strtab_size,
|
||||||
|
&errmsg, err);
|
||||||
|
if (strtab == NULL)
|
||||||
|
{
|
||||||
|
XDELETEVEC (symtab);
|
||||||
|
XDELETEVEC (scnbuf);
|
||||||
|
return errmsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n_offset >= strtab_size)
|
||||||
|
{
|
||||||
|
XDELETEVEC (strtab);
|
||||||
|
XDELETEVEC (symtab);
|
||||||
|
XDELETEVEC (scnbuf);
|
||||||
|
*err = 0;
|
||||||
|
return "section string index out of range";
|
||||||
|
}
|
||||||
|
n_name = strtab + n_offset;
|
||||||
|
|
||||||
|
if (!strcmp(n_name, ".go_export"))
|
||||||
|
{
|
||||||
|
/* Found .go_export symbol, read auxiliary entry. */
|
||||||
|
if (i + 1 >= ocr->nsyms)
|
||||||
|
break;
|
||||||
|
|
||||||
|
aux = (unsigned char *)&symtab[i + 1];
|
||||||
|
if (u64)
|
||||||
|
{
|
||||||
|
x_scnlen = fetch_32 (aux + offsetof (union external_auxent,
|
||||||
|
u.xcoff64.x_csect.x_scnlen_lo));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x_scnlen = fetch_32 (aux + offsetof (union external_auxent,
|
||||||
|
u.xcoff32.x_csect.x_scnlen));
|
||||||
|
}
|
||||||
|
(*pfn) (data, ".go_export", textptr + n_value, x_scnlen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Skip auxiliary entries. */
|
||||||
|
i += symtab[i].n_numaux[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symtab != NULL)
|
||||||
|
XDELETEVEC (symtab);
|
||||||
if (strtab != NULL)
|
if (strtab != NULL)
|
||||||
XDELETEVEC (strtab);
|
XDELETEVEC (strtab);
|
||||||
XDELETEVEC (scnbuf);
|
XDELETEVEC (scnbuf);
|
||||||
|
|
Loading…
Reference in New Issue