[patch]: Add MS __ImageBase symbol to 32-bit pe.em

Pedro Alves pedro_alves@portugalmail.pt
Fri Nov 2 15:31:00 GMT 2007


Kai Tietz wrote:

 > +#define MSIMAGEBASEOFF	2
 > +  D(ImageBase,"__ImageBase", NT_EXE_IMAGE_BASE),
 >    D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
 >    D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
 >    D(MajorOperatingSystemVersion,"__major_os_version__", 4),
 > @@ -374,6 +376,8 @@ set_pe_name (char *name, long val)
 >  	{
 >  	  init[i].value = val;
 >  	  init[i].inited = 1;
 > +	  if (strcmp (name,"__image_base__") == 0)
 > +	    set_pe_name ("__ImageBase", val);
 >

Shouldn't it be ___ImageBase (3 underscores) on i386 9x/NT
Windows, as opposed to x64, which I think I've read that it
is not underscored?  This file is also used for arm-wince,
which is not underscored.  (Although this __ImageBase thing
isn't as useful in Windows CE, because HMODULE == base address
isn't true there.)

You may use U take care of the differences between targets,
it's defined in the top of pe.em:

#define U(S) ${INITIAL_SYMBOL_CHAR} S

Where INITIAL_SYMBOL_CHAR is "_" in i386.

Like so:
+	    set_pe_name (U ("__ImageBase"), val);

Cheers,
Pedro Alves



More information about the Binutils mailing list