* [patch pe-coff]: Add support for IAT directory field
@ 2010-09-16 11:38 Kai Tietz
2010-09-16 14:43 ` Pierre Muller
[not found] ` <8289643880614229461@unknownmsgid>
0 siblings, 2 replies; 10+ messages in thread
From: Kai Tietz @ 2010-09-16 11:38 UTC (permalink / raw)
To: Binutils; +Cc: Dave Korn
[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]
Hello,
this patch implements to set correct values to the IAT directory entry
in PE's optional header. This field is mainly of interest for driver
development on windows and (AFAIK) for wince mobil. I provided this
patch some time ago for further enhancements, but now I got also a
request to support this feature for x86 & x64 windows binaries. So I
reworked patch a bit. As I don't have an arm wince to check this
patch, I would like to ask here to get feedback about wince from one
of its maintainers.
ChangeLog bfd
2010-09-16 Kai Tietz
* peXXigen.c (_bfd_XXi_final_link_postscript):
Add handling for setting IAT directory entry.
ChangeLog ld
2010-09-16 Kai Tietz
* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Add
idata to orphan set.
* emultempl/pep.em: Likewise.
* scripttempl/armcoff.sc: Separate idata
and add __IAT_start__ and __IAT_end__ labels.
* scripttempl/pe.sc: Likewise.
* scripttempl/pep.sc: Likewise.
Tested for x86_64-w64-mingw32, i686-pc-cygwin, i686-pc-mingw32, and
roughly for wince-arm target. Ok for apply?
Regards,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: IAT_pecoff.diff --]
[-- Type: application/octet-stream, Size: 7963 bytes --]
Index: src/bfd/peXXigen.c
===================================================================
--- src.orig/bfd/peXXigen.c 2010-09-14 22:23:20.000000000 +0200
+++ src/bfd/peXXigen.c 2010-09-16 13:17:12.033445400 +0200
@@ -2373,6 +2373,45 @@ _bfd_XXi_final_link_postscript (bfd * ab
result = FALSE;
}
}
+ else
+ {
+ h1 = coff_link_hash_lookup (coff_hash_table (info),
+ "__IAT_start__", FALSE, FALSE, TRUE);
+ if (h1 != NULL
+ && h1->root.u.def.section != NULL
+ && h1->root.u.def.section->output_section != NULL)
+ {
+ bfd_vma iat_va;
+
+ iat_va =
+ (h1->root.u.def.value
+ + h1->root.u.def.section->output_section->vma
+ + h1->root.u.def.section->output_offset);
+
+ h1 = coff_link_hash_lookup (coff_hash_table (info),
+ "__IAT_end__", FALSE, FALSE, TRUE);
+ if (h1 != NULL
+ && h1->root.u.def.section != NULL
+ && h1->root.u.def.section->output_section != NULL)
+ {
+ pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size =
+ ((h1->root.u.def.value
+ + h1->root.u.def.section->output_section->vma
+ + h1->root.u.def.section->output_offset)
+ - iat_va);
+ if (pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size != 0)
+ pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].VirtualAddress =
+ iat_va - pe_data (abfd)->pe_opthdr.ImageBase;
+ }
+ else
+ {
+ _bfd_error_handler
+ (_("%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)]"
+ " because .idata$6 is missing"), abfd);
+ result = FALSE;
+ }
+ }
+ }
h1 = coff_link_hash_lookup (coff_hash_table (info),
"__tls_used", FALSE, FALSE, TRUE);
Index: src/ld/emultempl/pe.em
===================================================================
--- src.orig/ld/emultempl/pe.em 2010-07-10 09:23:48.000000000 +0200
+++ src/ld/emultempl/pe.em 2010-09-16 10:51:49.586549900 +0200
@@ -1939,6 +1939,9 @@ gld_${EMULATION_NAME}_place_orphan (asec
{ ".text",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
0, 0, 0, 0 },
+ { ".idata",
+ SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
+ 0, 0, 0, 0 },
{ ".rdata",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
0, 0, 0, 0 },
@@ -1952,6 +1955,7 @@ gld_${EMULATION_NAME}_place_orphan (asec
enum orphan_save_index
{
orphan_text = 0,
+ orphan_idata,
orphan_rodata,
orphan_data,
orphan_bss
@@ -1985,7 +1989,12 @@ gld_${EMULATION_NAME}_place_orphan (asec
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if ((s->flags & SEC_CODE) == 0)
- place = &hold[orphan_rodata];
+ {
+ if (! strncmp (secname, ".idata\$", 7))
+ place = &hold[orphan_idata];
+ else
+ place = &hold[orphan_rodata];
+ }
else
place = &hold[orphan_text];
Index: src/ld/emultempl/pep.em
===================================================================
--- src.orig/ld/emultempl/pep.em 2010-05-25 12:00:49.000000000 +0200
+++ src/ld/emultempl/pep.em 2010-09-16 10:48:59.075797300 +0200
@@ -1677,6 +1677,9 @@ gld_${EMULATION_NAME}_place_orphan (asec
{ ".text",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
0, 0, 0, 0 },
+ { ".idata",
+ SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
+ 0, 0, 0, 0 },
{ ".rdata",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
0, 0, 0, 0 },
@@ -1690,6 +1693,7 @@ gld_${EMULATION_NAME}_place_orphan (asec
enum orphan_save_index
{
orphan_text = 0,
+ orphan_idata,
orphan_rodata,
orphan_data,
orphan_bss
@@ -1723,7 +1727,12 @@ gld_${EMULATION_NAME}_place_orphan (asec
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if ((s->flags & SEC_CODE) == 0)
- place = &hold[orphan_rodata];
+ {
+ if (! strncmp (secname, ".idata\$", 7))
+ place = &hold[orphan_idata];
+ else
+ place = &hold[orphan_rodata];
+ }
else
place = &hold[orphan_text];
Index: src/ld/scripttempl/armcoff.sc
===================================================================
--- src.orig/ld/scripttempl/armcoff.sc 2009-09-09 13:59:14.000000000 +0200
+++ src/ld/scripttempl/armcoff.sc 2010-09-16 10:55:36.798545700 +0200
@@ -17,7 +17,22 @@ DTOR='.dtor : {
*(SORT(.dtors.*))
*(.dtor)
}'
-
+if test "${RELOCATING}"; then
+ R_IDATA234='
+ SORT(*)(.idata$2)
+ SORT(*)(.idata$3)
+ /* These zeroes mark the end of the import list. */
+ LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
+ SORT(*)(.idata$6)
+ SORT(*)(.idata$7)'
+else
+ R_IDATA234=
+ R_IDATA5=
+ R_IDATA67=
+fi
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
${LIB_SEARCH_DIRS}
@@ -60,6 +75,16 @@ SECTIONS
}
${CONSTRUCTING+${RELOCATING-$CTOR}}
${CONSTRUCTING+${RELOCATING-$DTOR}}
+ .idata ${RELOCATING+BLOCK(__section_alignment__)} :
+ {
+ /* This cannot currently be handled with grouped sections.
+ See pep.em:sort_sections. */
+ ${R_IDATA234}
+ ${RELOCATING+__IAT_start__ = .;}
+ ${R_IDATA5}
+ ${RELOCATING+__IAT_end__ = .;}
+ ${R_IDATA67}
+ }
.bss ${RELOCATING+ ALIGN(0x8)} :
{
${RELOCATING+ __bss_start__ = . ;}
Index: src/ld/scripttempl/pe.sc
===================================================================
--- src.orig/ld/scripttempl/pe.sc 2009-11-25 07:59:01.000000000 +0100
+++ src/ld/scripttempl/pe.sc 2010-09-16 11:04:26.609849200 +0200
@@ -23,12 +23,14 @@ if test "${RELOCATING}"; then
R_RDATA='*(.rdata)
*(SORT(.rdata$*))'
fi
- R_IDATA='
+ R_IDATA234='
SORT(*)(.idata$2)
SORT(*)(.idata$3)
/* These zeroes mark the end of the import list. */
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
- SORT(*)(.idata$4)
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
SORT(*)(.idata$5)
SORT(*)(.idata$6)
SORT(*)(.idata$7)'
@@ -46,7 +48,9 @@ else
R_TEXT=
R_DATA=
R_RDATA='*(.rdata)'
- R_IDATA=
+ R_IDATA234=
+ R_IDATA5=
+ R_IDATA67=
R_CRT=
R_RSRC=
fi
@@ -147,7 +151,11 @@ SECTIONS
{
/* This cannot currently be handled with grouped sections.
See pe.em:sort_sections. */
- ${R_IDATA}
+ ${R_IDATA234}
+ ${RELOCATING+__IAT_start__ = .;}
+ ${R_IDATA5}
+ ${RELOCATING+__IAT_end__ = .;}
+ ${R_IDATA67}
}
.CRT ${RELOCATING+BLOCK(__section_alignment__)} :
{
Index: src/ld/scripttempl/pep.sc
===================================================================
--- src.orig/ld/scripttempl/pep.sc 2010-09-15 21:38:46.000000000 +0200
+++ src/ld/scripttempl/pep.sc 2010-09-16 11:01:33.897970600 +0200
@@ -23,13 +23,14 @@ if test "${RELOCATING}"; then
R_RDATA='*(.rdata)
*(SORT(.rdata$*))'
fi
- R_IDATA='
+ R_IDATA234='
SORT(*)(.idata$2)
SORT(*)(.idata$3)
/* These zeroes mark the end of the import list. */
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
- SORT(*)(.idata$4)
- SORT(*)(.idata$5)
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
SORT(*)(.idata$6)
SORT(*)(.idata$7)'
R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */'
@@ -46,7 +47,9 @@ else
R_TEXT=
R_DATA=
R_RDATA='*(.rdata)'
- R_IDATA=
+ R_IDATA234=
+ R_IDATA5=
+ R_IDATA67=
R_CRT=
R_RSRC=
fi
@@ -153,7 +156,11 @@ SECTIONS
{
/* This cannot currently be handled with grouped sections.
See pep.em:sort_sections. */
- ${R_IDATA}
+ ${R_IDATA234}
+ ${RELOCATING+__IAT_start__ = .;}
+ ${R_IDATA5}
+ ${RELOCATING+__IAT_end__ = .;}
+ ${R_IDATA67}
}
.CRT ${RELOCATING+BLOCK(__section_alignment__)} :
{
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [patch pe-coff]: Add support for IAT directory field
2010-09-16 11:38 [patch pe-coff]: Add support for IAT directory field Kai Tietz
@ 2010-09-16 14:43 ` Pierre Muller
[not found] ` <8289643880614229461@unknownmsgid>
1 sibling, 0 replies; 10+ messages in thread
From: Pierre Muller @ 2010-09-16 14:43 UTC (permalink / raw)
To: 'Kai Tietz'; +Cc: binutils
Hi all,
I just looked at the patch out of curiosity,
and it seems that in
src/ld/scripttempl/pe.sc
you have 'SORT(*) (.idata$5)
twice:
- SORT(*)(.idata$4)
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
SORT(*)(.idata$5)
SORT(*)(.idata$6)
SORT(*)(.idata$7)'
src/ld/scripttempl/pep.sc
doesn't have this repetition...
Is this an error or does it have a special purpose?
Pierre Muller
Pascal language support maintainer for GDB
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
[not found] ` <8289643880614229461@unknownmsgid>
@ 2010-09-16 14:46 ` Kai Tietz
2010-09-20 8:36 ` Kai Tietz
0 siblings, 1 reply; 10+ messages in thread
From: Kai Tietz @ 2010-09-16 14:46 UTC (permalink / raw)
To: Pierre Muller; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 881 bytes --]
2010/9/16 Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>:
> Hi all,
>
> I just looked at the patch out of curiosity,
> and it seems that in
> src/ld/scripttempl/pe.sc
> you have 'SORT(*) (.idata$5)
> twice:
>
>
> - SORT(*)(.idata$4)
> + SORT(*)(.idata$4)'
> + R_IDATA5='SORT(*)(.idata$5)'
> + R_IDATA67='
> SORT(*)(.idata$5)
> SORT(*)(.idata$6)
> SORT(*)(.idata$7)'
>
> src/ld/scripttempl/pep.sc
> doesn't have this repetition...
>
> Is this an error or does it have a special purpose?
>
>
> Pierre Muller
> Pascal language support maintainer for GDB
>
>
Thanks for catching this. This is an error (but well, it didn't showed
any test-failures).
Attached patch with fixing that.
Cheers,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
[-- Attachment #2: IAT_pecoff.diff --]
[-- Type: application/octet-stream, Size: 8019 bytes --]
Index: src/bfd/peXXigen.c
===================================================================
--- src.orig/bfd/peXXigen.c 2010-09-14 22:23:20.000000000 +0200
+++ src/bfd/peXXigen.c 2010-09-16 13:17:12.033445400 +0200
@@ -2373,6 +2373,45 @@ _bfd_XXi_final_link_postscript (bfd * ab
result = FALSE;
}
}
+ else
+ {
+ h1 = coff_link_hash_lookup (coff_hash_table (info),
+ "__IAT_start__", FALSE, FALSE, TRUE);
+ if (h1 != NULL
+ && h1->root.u.def.section != NULL
+ && h1->root.u.def.section->output_section != NULL)
+ {
+ bfd_vma iat_va;
+
+ iat_va =
+ (h1->root.u.def.value
+ + h1->root.u.def.section->output_section->vma
+ + h1->root.u.def.section->output_offset);
+
+ h1 = coff_link_hash_lookup (coff_hash_table (info),
+ "__IAT_end__", FALSE, FALSE, TRUE);
+ if (h1 != NULL
+ && h1->root.u.def.section != NULL
+ && h1->root.u.def.section->output_section != NULL)
+ {
+ pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size =
+ ((h1->root.u.def.value
+ + h1->root.u.def.section->output_section->vma
+ + h1->root.u.def.section->output_offset)
+ - iat_va);
+ if (pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].Size != 0)
+ pe_data (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].VirtualAddress =
+ iat_va - pe_data (abfd)->pe_opthdr.ImageBase;
+ }
+ else
+ {
+ _bfd_error_handler
+ (_("%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)]"
+ " because .idata$6 is missing"), abfd);
+ result = FALSE;
+ }
+ }
+ }
h1 = coff_link_hash_lookup (coff_hash_table (info),
"__tls_used", FALSE, FALSE, TRUE);
Index: src/ld/emultempl/pe.em
===================================================================
--- src.orig/ld/emultempl/pe.em 2010-07-10 09:23:48.000000000 +0200
+++ src/ld/emultempl/pe.em 2010-09-16 10:51:49.586549900 +0200
@@ -1939,6 +1939,9 @@ gld_${EMULATION_NAME}_place_orphan (asec
{ ".text",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
0, 0, 0, 0 },
+ { ".idata",
+ SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
+ 0, 0, 0, 0 },
{ ".rdata",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
0, 0, 0, 0 },
@@ -1952,6 +1955,7 @@ gld_${EMULATION_NAME}_place_orphan (asec
enum orphan_save_index
{
orphan_text = 0,
+ orphan_idata,
orphan_rodata,
orphan_data,
orphan_bss
@@ -1985,7 +1989,12 @@ gld_${EMULATION_NAME}_place_orphan (asec
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if ((s->flags & SEC_CODE) == 0)
- place = &hold[orphan_rodata];
+ {
+ if (! strncmp (secname, ".idata\$", 7))
+ place = &hold[orphan_idata];
+ else
+ place = &hold[orphan_rodata];
+ }
else
place = &hold[orphan_text];
Index: src/ld/emultempl/pep.em
===================================================================
--- src.orig/ld/emultempl/pep.em 2010-05-25 12:00:49.000000000 +0200
+++ src/ld/emultempl/pep.em 2010-09-16 10:48:59.075797300 +0200
@@ -1677,6 +1677,9 @@ gld_${EMULATION_NAME}_place_orphan (asec
{ ".text",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
0, 0, 0, 0 },
+ { ".idata",
+ SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
+ 0, 0, 0, 0 },
{ ".rdata",
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA,
0, 0, 0, 0 },
@@ -1690,6 +1693,7 @@ gld_${EMULATION_NAME}_place_orphan (asec
enum orphan_save_index
{
orphan_text = 0,
+ orphan_idata,
orphan_rodata,
orphan_data,
orphan_bss
@@ -1723,7 +1727,12 @@ gld_${EMULATION_NAME}_place_orphan (asec
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if ((s->flags & SEC_CODE) == 0)
- place = &hold[orphan_rodata];
+ {
+ if (! strncmp (secname, ".idata\$", 7))
+ place = &hold[orphan_idata];
+ else
+ place = &hold[orphan_rodata];
+ }
else
place = &hold[orphan_text];
Index: src/ld/scripttempl/armcoff.sc
===================================================================
--- src.orig/ld/scripttempl/armcoff.sc 2009-09-09 13:59:14.000000000 +0200
+++ src/ld/scripttempl/armcoff.sc 2010-09-16 10:55:36.798545700 +0200
@@ -17,7 +17,22 @@ DTOR='.dtor : {
*(SORT(.dtors.*))
*(.dtor)
}'
-
+if test "${RELOCATING}"; then
+ R_IDATA234='
+ SORT(*)(.idata$2)
+ SORT(*)(.idata$3)
+ /* These zeroes mark the end of the import list. */
+ LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
+ SORT(*)(.idata$6)
+ SORT(*)(.idata$7)'
+else
+ R_IDATA234=
+ R_IDATA5=
+ R_IDATA67=
+fi
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", "${LITTLE_OUTPUT_FORMAT}")
${LIB_SEARCH_DIRS}
@@ -60,6 +75,16 @@ SECTIONS
}
${CONSTRUCTING+${RELOCATING-$CTOR}}
${CONSTRUCTING+${RELOCATING-$DTOR}}
+ .idata ${RELOCATING+BLOCK(__section_alignment__)} :
+ {
+ /* This cannot currently be handled with grouped sections.
+ See pep.em:sort_sections. */
+ ${R_IDATA234}
+ ${RELOCATING+__IAT_start__ = .;}
+ ${R_IDATA5}
+ ${RELOCATING+__IAT_end__ = .;}
+ ${R_IDATA67}
+ }
.bss ${RELOCATING+ ALIGN(0x8)} :
{
${RELOCATING+ __bss_start__ = . ;}
Index: src/ld/scripttempl/pe.sc
===================================================================
--- src.orig/ld/scripttempl/pe.sc 2009-11-25 07:59:01.000000000 +0100
+++ src/ld/scripttempl/pe.sc 2010-09-16 16:45:02.013687400 +0200
@@ -23,13 +23,14 @@ if test "${RELOCATING}"; then
R_RDATA='*(.rdata)
*(SORT(.rdata$*))'
fi
- R_IDATA='
+ R_IDATA234='
SORT(*)(.idata$2)
SORT(*)(.idata$3)
/* These zeroes mark the end of the import list. */
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
- SORT(*)(.idata$4)
- SORT(*)(.idata$5)
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
SORT(*)(.idata$6)
SORT(*)(.idata$7)'
R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */'
@@ -46,7 +47,9 @@ else
R_TEXT=
R_DATA=
R_RDATA='*(.rdata)'
- R_IDATA=
+ R_IDATA234=
+ R_IDATA5=
+ R_IDATA67=
R_CRT=
R_RSRC=
fi
@@ -147,7 +150,11 @@ SECTIONS
{
/* This cannot currently be handled with grouped sections.
See pe.em:sort_sections. */
- ${R_IDATA}
+ ${R_IDATA234}
+ ${RELOCATING+__IAT_start__ = .;}
+ ${R_IDATA5}
+ ${RELOCATING+__IAT_end__ = .;}
+ ${R_IDATA67}
}
.CRT ${RELOCATING+BLOCK(__section_alignment__)} :
{
Index: src/ld/scripttempl/pep.sc
===================================================================
--- src.orig/ld/scripttempl/pep.sc 2010-09-15 21:38:46.000000000 +0200
+++ src/ld/scripttempl/pep.sc 2010-09-16 11:01:33.897970600 +0200
@@ -23,13 +23,14 @@ if test "${RELOCATING}"; then
R_RDATA='*(.rdata)
*(SORT(.rdata$*))'
fi
- R_IDATA='
+ R_IDATA234='
SORT(*)(.idata$2)
SORT(*)(.idata$3)
/* These zeroes mark the end of the import list. */
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
- SORT(*)(.idata$4)
- SORT(*)(.idata$5)
+ SORT(*)(.idata$4)'
+ R_IDATA5='SORT(*)(.idata$5)'
+ R_IDATA67='
SORT(*)(.idata$6)
SORT(*)(.idata$7)'
R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */'
@@ -46,7 +47,9 @@ else
R_TEXT=
R_DATA=
R_RDATA='*(.rdata)'
- R_IDATA=
+ R_IDATA234=
+ R_IDATA5=
+ R_IDATA67=
R_CRT=
R_RSRC=
fi
@@ -153,7 +156,11 @@ SECTIONS
{
/* This cannot currently be handled with grouped sections.
See pep.em:sort_sections. */
- ${R_IDATA}
+ ${R_IDATA234}
+ ${RELOCATING+__IAT_start__ = .;}
+ ${R_IDATA5}
+ ${RELOCATING+__IAT_end__ = .;}
+ ${R_IDATA67}
}
.CRT ${RELOCATING+BLOCK(__section_alignment__)} :
{
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-16 14:46 ` Kai Tietz
@ 2010-09-20 8:36 ` Kai Tietz
2010-09-22 4:59 ` Dave Korn
0 siblings, 1 reply; 10+ messages in thread
From: Kai Tietz @ 2010-09-20 8:36 UTC (permalink / raw)
To: Pierre Muller; +Cc: binutils
PING
Regards,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-20 8:36 ` Kai Tietz
@ 2010-09-22 4:59 ` Dave Korn
2010-09-22 8:06 ` Kai Tietz
0 siblings, 1 reply; 10+ messages in thread
From: Dave Korn @ 2010-09-22 4:59 UTC (permalink / raw)
To: Kai Tietz; +Cc: Pierre Muller, binutils
On 20/09/2010 09:36, Kai Tietz wrote:
> PING
>
> Regards,
> Kai
Good morning Kai,
> + "__IAT_start__", FALSE, FALSE, TRUE);
Mixed spaces/TABs at the start of the line.
+ pe_data
(abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].VirtualAddress =
Here, eight spaces after the first TAB should be a second TAB.
> + }
Also here at the end, eight spaces should be a tab.
> + {
> + if (! strncmp (secname, ".idata\$", 7))
> + place = &hold[orphan_idata];
> + else
> + place = &hold[orphan_rodata];
> + }
Likewise here, formatting vs. spaces and TABs. I'd probably be inclined to
just use a ternary operator here like
else if ((s->flags & SEC_READONLY) == 0)
place = &hold[orphan_data];
else if ((s->flags & SEC_CODE) == 0)
- place = &hold[orphan_rodata];
+ place = ! strncmp (secname, ".idata\$", 7)
+ ? &hold[orphan_idata]
+ : &hold[orphan_rodata];
else
place = &hold[orphan_text];
that but it doesn't matter. Formatting issues aside, I have one issue with
the actual code, in the way you treat results looked up in the hash table; for
example, here...
> + h1 = coff_link_hash_lookup (coff_hash_table (info),
> + "__IAT_start__", FALSE, FALSE, TRUE);
> + if (h1 != NULL
> + && h1->root.u.def.section != NULL
> + && h1->root.u.def.section->output_section != NULL)
> + {
I don't think you should unconditionally assume that the type of h1 is
necessarily a defined symbol here. All the other code in that function
verifies the expected type of symbol in h1->root.type, and so should your code.
OK once that and the formatting is fixed.
cheers,
DaveK
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-22 4:59 ` Dave Korn
@ 2010-09-22 8:06 ` Kai Tietz
2010-09-23 5:21 ` Alan Modra
0 siblings, 1 reply; 10+ messages in thread
From: Kai Tietz @ 2010-09-22 8:06 UTC (permalink / raw)
To: Dave Korn; +Cc: binutils, Kai Tietz, Pierre Muller
binutils-owner@sourceware.org wrote on 22.09.2010 07:21:41:
> On 20/09/2010 09:36, Kai Tietz wrote:
> > PING
> >
> > Regards,
> > Kai
>
> Good morning Kai,
>
> > + "__IAT_start__", FALSE, FALSE, TRUE);
>
> Mixed spaces/TABs at the start of the line.
>
> + pe_data
> (abfd)->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE].VirtualAddress
=
>
> Here, eight spaces after the first TAB should be a second TAB.
>
> > + }
>
> Also here at the end, eight spaces should be a tab.
>
> > + {
> > + if (! strncmp (secname, ".idata\$", 7))
> > + place = &hold[orphan_idata];
> > + else
> > + place = &hold[orphan_rodata];
> > + }
>
> Likewise here, formatting vs. spaces and TABs. I'd probably be
inclined to
> just use a ternary operator here like
>
> else if ((s->flags & SEC_READONLY) == 0)
> place = &hold[orphan_data];
> else if ((s->flags & SEC_CODE) == 0)
> - place = &hold[orphan_rodata];
> + place = ! strncmp (secname, ".idata\$", 7)
> + ? &hold[orphan_idata]
> + : &hold[orphan_rodata];
> else
> place = &hold[orphan_text];
>
> that but it doesn't matter. Formatting issues aside, I have one issue
with
> the actual code, in the way you treat results looked up in the hash
table; for
> example, here...
>
> > + h1 = coff_link_hash_lookup (coff_hash_table (info),
> > + "__IAT_start__", FALSE, FALSE, TRUE);
> > + if (h1 != NULL
> > + && h1->root.u.def.section != NULL
> > + && h1->root.u.def.section->output_section != NULL)
> > + {
>
> I don't think you should unconditionally assume that the type of h1 is
> necessarily a defined symbol here. All the other code in that function
> verifies the expected type of symbol in h1->root.type, and so shouldyour
code.
>
> OK once that and the formatting is fixed.
>
> cheers,
> DaveK
>
>
>
Good morning Dave,
Thanks for review. Ok, adjusted whitespaces and add suggested
modifications and applied after testing.
Regards,
Kai
| (\_/) This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-22 8:06 ` Kai Tietz
@ 2010-09-23 5:21 ` Alan Modra
2010-09-23 6:51 ` Kai Tietz
0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2010-09-23 5:21 UTC (permalink / raw)
To: Kai Tietz; +Cc: Dave Korn, binutils, Kai Tietz, Pierre Muller
On Wed, Sep 22, 2010 at 10:06:09AM +0200, Kai Tietz wrote:
> Thanks for review. Ok, adjusted whitespaces and add suggested
> modifications and applied after testing.
This addition to armcoff.sc
.idata BLOCK(__section_alignment__) :
results in
built in linker script:72: non constant or forward reference address expression for section .idata
FAIL: check sections 1
FAIL: --entry foo archive
FAIL: --entry foo -u foo archive
FAIL: --entry foo
FAIL: --entry foo -u foo
FAIL: --entry 0x0
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-23 5:21 ` Alan Modra
@ 2010-09-23 6:51 ` Kai Tietz
2010-09-24 4:38 ` Dave Korn
0 siblings, 1 reply; 10+ messages in thread
From: Kai Tietz @ 2010-09-23 6:51 UTC (permalink / raw)
To: Kai Tietz, Dave Korn, binutils, Kai Tietz, Pierre Muller
2010/9/23 Alan Modra <amodra@gmail.com>:
> On Wed, Sep 22, 2010 at 10:06:09AM +0200, Kai Tietz wrote:
>> Thanks for review. Ok, adjusted whitespaces and add suggested
>> modifications and applied after testing.
>
> This addition to armcoff.sc
> .idata BLOCK(__section_alignment__) :
>
> results in
>
> built in linker script:72: non constant or forward reference address expression for section .idata
> FAIL: check sections 1
> FAIL: --entry foo archive
> FAIL: --entry foo -u foo archive
> FAIL: --entry foo
> FAIL: --entry foo -u foo
> FAIL: --entry 0x0
>
> --
> Alan Modra
> Australia Development Lab, IBM
>
Hmm, sorry for that. Does it help to replace __section_alignment__ by
constant 0x1000? Otherwise I can revert the change here for
coffarm.sc.
Regards,
Kai
--
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-23 6:51 ` Kai Tietz
@ 2010-09-24 4:38 ` Dave Korn
2010-09-24 8:15 ` Kai Tietz
0 siblings, 1 reply; 10+ messages in thread
From: Dave Korn @ 2010-09-24 4:38 UTC (permalink / raw)
To: Kai Tietz; +Cc: Kai Tietz, binutils, Pierre Muller
On 23/09/2010 07:51, Kai Tietz wrote:
> Hmm, sorry for that. Does it help to replace __section_alignment__ by
> constant 0x1000? Otherwise I can revert the change here for
> coffarm.sc.
Not having heard back from you yet, I've looked at it further and just got
confused. The armcoff.sc template isn't used by any of the Arm PE targets, so
I don't see the reason for modifying it in this patch. I'm going to revert
that part of the change.
cheers,
DaveK
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch pe-coff]: Add support for IAT directory field
2010-09-24 4:38 ` Dave Korn
@ 2010-09-24 8:15 ` Kai Tietz
0 siblings, 0 replies; 10+ messages in thread
From: Kai Tietz @ 2010-09-24 8:15 UTC (permalink / raw)
To: Dave Korn; +Cc: binutils, Kai Tietz, Pierre Muller
Dave Korn <dave.korn.cygwin@gmail.com> wrote on 24.09.2010 07:00:33:
> On 23/09/2010 07:51, Kai Tietz wrote:
>
> > Hmm, sorry for that. Does it help to replace __section_alignment__ by
> > constant 0x1000? Otherwise I can revert the change here for
> > coffarm.sc.
>
> Not having heard back from you yet, I've looked at it further and just
got
> confused. The armcoff.sc template isn't used by any of the Arm PE
targets, so
> I don't see the reason for modifying it in this patch. I'm going to
revert
> that part of the change.
>
> cheers,
> DaveK
>
Yes, it seems I was here confused, too. Reverting it is right. Sorry for
the noise.
Regards,
Kai
| (\_/) This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-09-24 8:15 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-16 11:38 [patch pe-coff]: Add support for IAT directory field Kai Tietz
2010-09-16 14:43 ` Pierre Muller
[not found] ` <8289643880614229461@unknownmsgid>
2010-09-16 14:46 ` Kai Tietz
2010-09-20 8:36 ` Kai Tietz
2010-09-22 4:59 ` Dave Korn
2010-09-22 8:06 ` Kai Tietz
2010-09-23 5:21 ` Alan Modra
2010-09-23 6:51 ` Kai Tietz
2010-09-24 4:38 ` Dave Korn
2010-09-24 8:15 ` Kai Tietz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).