arm-wince-pe objdump does not disassemble .text section

Dmitry Semyonov Dmitry.Semyonov@oktet.ru
Tue Nov 11 16:46:00 GMT 2003


Hello Nick.

On Tue, 11 Nov 2003, Nick Clifton wrote:

> > I've compiled binutils/gcc for arm-wince-pe target.
> > Using the tools I'm trying to compile sample file probe.c with the
> > following function:
> >
> > int foo(int a)
> > {
> >     return a * 2;
> > }
> >
> > Then I'm doing arm-wince-pe-objdump -d probe.o
> > and seeing only the following line:
> >
> > probe.o:     file format pe-arm-little
> >
> > Where is the disassembled instructions?
> > Is it a bug in binutils, or may be I misunderstand something?
>
> It is a bug in binutils.
>
> A workaround is to use the -D switch to objdump instead of -d.  (The
> bug is that the .text section is being created without the EXECUTABLE
> attribute, so objdump does not know that it contains instructions).

-D does not work either.


> The solution is to apply this patch to your sources and rebuild libbfd
> and objdump.

Thank you.
Currently I have no time to evaluate your patch since I've already
applied my own (see attachment), and it works for me. (I'm trying to
link GCC produced object files using WinCE4.2 linker, and have another
compatibility issue in the way).

Don't know for sure which approach is better...
Note that MS linker will continue to produce warnings due to different
section flags (.rdata sections in GCC's objects and WinCE's objects)
with your approach. (See MS PE & COFF Rev. 6.0, section 6).
On the other hand my patch may be incomplete (not all special sections
are handled), or it may even brake another binutils functionality.
Therefore, I don't insist on applying my variant.


> 2003-07-24  Nick Clifton  <nickc@redhat.com>
>
> 	* coff-arm.c (EXTRA_S_FLAGS): Include SEC_CODE so that code
> 	sections are assigned the LOAD attribute.
>
> Index: bfd/coff-arm.c
> ===================================================================
> RCS file: /repositories/repositories/sourceware/src/bfd/coff-arm.c,v
> retrieving revision 1.43
> diff -c -3 -p -r1.43 coff-arm.c
> *** bfd/coff-arm.c	1 Apr 2003 13:08:05 -0000	1.43
> --- bfd/coff-arm.c	11 Nov 2003 10:46:59 -0000
> *************** coff_arm_final_link_postscript (abfd, pf
> *** 2613,2621 ****
>
>   #ifndef EXTRA_S_FLAGS
>   #ifdef COFF_WITH_PE
> ! #define EXTRA_S_FLAGS (SEC_LINK_ONCE | SEC_LINK_DUPLICATES)
>   #else
> ! #define EXTRA_S_FLAGS 0
>   #endif
>   #endif
>
> --- 2613,2621 ----
>
>   #ifndef EXTRA_S_FLAGS
>   #ifdef COFF_WITH_PE
> ! #define EXTRA_S_FLAGS (SEC_CODE | SEC_LINK_ONCE | SEC_LINK_DUPLICATES)
>   #else
> ! #define EXTRA_S_FLAGS SEC_CODE
>   #endif
>   #endif
>
>
>


...Bye..Dmitry.


-------------- next part --------------
diff -rc3p binutils-2.14/bfd/peXXigen.c /home/sdv/cross/binutils-2.14/bfd/peXXigen.c
*** binutils-2.14/bfd/peXXigen.c	Thu Apr  3 15:13:26 2003
--- /home/sdv/cross/binutils-2.14/bfd/peXXigen.c	Fri Nov  7 20:07:47 2003
*************** _bfd_XXi_swap_scnhdr_out (abfd, in, out)
*** 956,961 ****
--- 956,990 ----
  
    {
      int flags = scnhdr_int->s_flags;
+     
+     if (strcmp (scnhdr_int->s_name, ".text") == 0)
+       {
+         /* Executable code */
+         flags &= ~IMAGE_SCN_MEM_WRITE;
+         flags |= IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE |
+                  IMAGE_SCN_MEM_READ;
+       }
+     else if (strcmp (scnhdr_int->s_name, ".rdata") == 0)
+       {
+         /* Read-only initialized data */
+         flags &= ~IMAGE_SCN_MEM_WRITE;
+         flags |= IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ;
+       }
+     else if (strcmp (scnhdr_int->s_name, ".data") == 0)
+       {
+         /* Initialized data */
+         flags |= IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+                  IMAGE_SCN_MEM_WRITE;
+       }
+     else if (strcmp (scnhdr_int->s_name, ".bss") == 0)
+       {
+         /* Uninitialized data */
+         flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+                  IMAGE_SCN_MEM_WRITE;
+       }
+ 
+     /* FIXME: Still not all reserved sections and their characteristics
+      *        are covered here. */
  
      H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
    }


More information about the Binutils mailing list