[linux-unicore] Re: [linux-unicore] 答复: [linux-unicore] [PATCH/binutils] Add definitions and stubs for building bfd.

  • From: 刘智猷 <liuzhiyou.cs@xxxxxxxxx>
  • To: linux-unicore@xxxxxxxxxxxxx
  • Date: Wed, 23 Jan 2013 00:32:14 +0800

2013/1/22 Guan Xuetao <gxt@xxxxxxxxxxxxxxx>:
>
>
>> -----邮件原件-----
>> 发件人: linux-unicore-bounce@xxxxxxxxxxxxx
>> [mailto:linux-unicore-bounce@xxxxxxxxxxxxx] 代表 LIU Zhiyou
>> 发送时间: Saturday, January 19, 2013 18:25
>> 收件人: gxt@xxxxxxxxxxxxxxx; linux-unicore@xxxxxxxxxxxxx
>> 抄送: LIU Zhiyou
>> 主题: [linux-unicore] [PATCH/binutils] Add definitions and stubs for
> building bfd.
>>
>> After applied this patch, bfd can be builded successfully. i.e
>>
>> $ make
>> will runinto
>> .......snip.......
>> make[1]: *** [configure-opcodes] Error 1 .......snip.......
>>
>> Makefile.in, configure and bfd-in2.h are generate by other files.
>> So their changes can be safely ignored.
>>
>> Makefile.in are regenerated from Makefile.am by automake-1.11.1 configure
>> are regenerated from configure.in by autoconf-2.64 bfd-in2.h can be
>> regenrated by make headers.
>> Please notice that the version of automake and autoconf are really
> _important_
>> if you want to do it by yourself.
> 这部分也是一块缺失的工作,以后再说吧。
我有这两个版本的autoconf和automake。
>
>>
>> Signed-off-by: LIU Zhiyou <liuzhiyou.cs@xxxxxxxxx>
>> ---
>>  bfd/Makefile.am       |  4 ++++
>>  bfd/Makefile.in       |  8 +++++++-
>>  bfd/archures.c        |  1 +
>>  bfd/bfd-in2.h         |  2 ++
>>  bfd/configure         |  2 +-
>>  bfd/configure.in      |  1 +
>>  bfd/cpu-unicore32.c   |  9 +++++----
>>  bfd/elf32-unicore32.c | 18 ++++++++++++++++++  include/elf/common.h  |
>> 2 +-
>>  9 files changed, 40 insertions(+), 7 deletions(-)
>>
>> diff --git a/bfd/Makefile.am b/bfd/Makefile.am index d86d899..a544da6
> 100644
>> --- a/bfd/Makefile.am
>> +++ b/bfd/Makefile.am
>> @@ -140,6 +140,7 @@ ALL_MACHINES = \
>>       cpu-tic80.lo \
>>       cpu-tilegx.lo \
>>       cpu-tilepro.lo \
>> +     cpu-unicore32.lo \
>>       cpu-v850.lo \
>>       cpu-v850_rh850.lo \
>>       cpu-vax.lo \
>> @@ -222,6 +223,7 @@ ALL_MACHINES_CFILES = \
>>       cpu-tic80.c \
>>       cpu-tilegx.c \
>>       cpu-tilepro.c \
>> +     cpu-unicore32.c \
>>       cpu-v850.c \
>>       cpu-v850_rh850.c \
>>       cpu-vax.c \
>> @@ -344,6 +346,7 @@ BFD32_BACKENDS = \
>>       elf32-tic6x.lo \
>>       elf32-tilegx.lo \
>>       elf32-tilepro.lo \
>> +     elf32-unicore32.lo \
>>       elf32-v850.lo \
>>       elf32-vax.lo \
>>       elf32-xc16x.lo \
>> @@ -532,6 +535,7 @@ BFD32_BACKENDS_CFILES = \
>>       elf32-tic6x.c \
>>       elf32-tilegx.c \
>>       elf32-tilepro.c \
>> +     elf32-unicore32.c \
>>       elf32-v850.c \
>>       elf32-vax.c \
>>       elf32-xc16x.c \
>> diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 92d9d08..2ea2830
> 100644
>> --- a/bfd/Makefile.in
>> +++ b/bfd/Makefile.in
>> @@ -440,6 +440,7 @@ ALL_MACHINES = \
>>       cpu-tic80.lo \
>>       cpu-tilegx.lo \
>>       cpu-tilepro.lo \
>> +     cpu-unicore32.lo \
>>       cpu-v850.lo \
>>       cpu-v850_rh850.lo \
>>       cpu-vax.lo \
>> @@ -522,6 +523,7 @@ ALL_MACHINES_CFILES = \
>>       cpu-tic80.c \
>>       cpu-tilegx.c \
>>       cpu-tilepro.c \
>> +     cpu-unicore32.c \
>>       cpu-v850.c \
>>       cpu-v850_rh850.c \
>>       cpu-vax.c \
>> @@ -645,6 +647,7 @@ BFD32_BACKENDS = \
>>       elf32-tic6x.lo \
>>       elf32-tilegx.lo \
>>       elf32-tilepro.lo \
>> +     elf32-unicore32.lo \
>>       elf32-v850.lo \
>>       elf32-vax.lo \
>>       elf32-xc16x.lo \
>> @@ -833,6 +836,7 @@ BFD32_BACKENDS_CFILES = \
>>       elf32-tic6x.c \
>>       elf32-tilegx.c \
>>       elf32-tilepro.c \
>> +     elf32-unicore32.c \
>>       elf32-v850.c \
>>       elf32-vax.c \
>>       elf32-xc16x.c \
>> @@ -1346,8 +1350,9 @@ distclean-compile:
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-tic80.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-tilegx.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-tilepro.Plo@am__quote@
>> -@AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-v850_rh850.Plo@am__quote@
>> +@AMDEP_TRUE@@am__include@
>> +@am__quote@./$(DEPDIR)/cpu-unicore32.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
> 我用outlook看的格式可能不对,这里是按字母排序的,而我看到的有些错误
Makefile.in是用automake从Makefile.am生成的,我没有做额外的改动。
>
>> @am__quote@./$(DEPDIR)/cpu-v850.Plo@am__quote@
>> +@AMDEP_TRUE@@am__include@
>> +@am__quote@./$(DEPDIR)/cpu-v850_rh850.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-vax.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-w65.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/cpu-we32k.Plo@am__quote@
>> @@ -1429,6 +1434,7 @@ distclean-compile:
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/elf32-tic6x.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/elf32-tilegx.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/elf32-tilepro.Plo@am__quote@
>> +@AMDEP_TRUE@@am__include@
>> +@am__quote@./$(DEPDIR)/elf32-unicore32.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/elf32-v850.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/elf32-vax.Plo@am__quote@
>>  @AMDEP_TRUE@@am__include@
>> @am__quote@./$(DEPDIR)/elf32-xc16x.Plo@am__quote@
>> diff --git a/bfd/archures.c b/bfd/archures.c index aedde6b..6afbaa5 100644
>> --- a/bfd/archures.c
>> +++ b/bfd/archures.c
>> @@ -424,6 +424,7 @@ DESCRIPTION
>>  .  bfd_arch_openrisc,  {* OpenRISC *}
>>  .  bfd_arch_mmix,      {* Donald Knuth's educational processor.  *}
>>  .  bfd_arch_unicore32,  {* UniCore32 *}
>> +.#define bfd_mach_unicore32          1
>>  .  bfd_arch_xstormy16,
>>  .#define bfd_mach_xstormy16  1
>>  .  bfd_arch_msp430,    {* Texas Instruments MSP430 architecture.  *}
>> diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index bba8757..8db0901 100644
>> --- a/bfd/bfd-in2.h
>> +++ b/bfd/bfd-in2.h
>> @@ -2154,6 +2154,8 @@ enum bfd_architecture
>>  #define bfd_mach_score7         7
>>    bfd_arch_openrisc,  /* OpenRISC */
>>    bfd_arch_mmix,      /* Donald Knuth's educational processor.  */
>> +  bfd_arch_unicore32,  /* UniCore32 */
>> +#define bfd_mach_unicore32             1
> 和上面一样的定义是否需要定义两次?
bfd-in2.h是自动生成的。
>
>>    bfd_arch_xstormy16,
>>  #define bfd_mach_xstormy16     1
>>    bfd_arch_msp430,    /* Texas Instruments MSP430 architecture.  */
>> diff --git a/bfd/configure b/bfd/configure index 6646e68..6d41a70 100755
>> --- a/bfd/configure
>> +++ b/bfd/configure
>> @@ -15347,11 +15347,11 @@ do
>>                               tb="$tb elf32-mips.lo elfxx-mips.lo
> elf-vxworks.lo elf32.lo
>> $elf ecofflink.lo" ;;
>>      bfd_elf32_tradlittlemips_vec | bfd_elf32_tradlittlemips_freebsd_vec)
>>                               tb="$tb elf32-mips.lo elfxx-mips.lo
> elf-vxworks.lo elf32.lo
>> $elf ecofflink.lo" ;;
>> -    bfd_elf32_unicore32_vec)   tb="$tb elf32-unicore32.lo elf32.lo $elf"
> ;;
>>      bfd_elf32_us_cris_vec)   tb="$tb elf32-cris.lo elf32.lo $elf" ;;
>>      bfd_elf32_v850_vec)              tb="$tb elf32-v850.lo elf32.lo $elf"
> ;;
>>      bfd_elf32_v850_rh850_vec)        tb="$tb elf32-v850.lo elf32.lo $elf"
> ;;
>>      bfd_elf32_vax_vec)               tb="$tb elf32-vax.lo elf32.lo $elf"
> ;;
>> +    bfd_elf32_unicore32_vec)         tb="$tb elf32-unicore32.lo elf32.lo
>> $elf" ;;
> 这里不需要挪位置
configure是从configure.in生成过来的。也许我应该让这个patch基于没有修改过configure的时候。
>
>>      bfd_elf32_xstormy16_vec) tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
>>      bfd_elf32_xc16x_vec)             tb="$tb elf32-xc16x.lo elf32.lo
> $elf" ;;
>>      bfd_elf32_xgate_vec)     tb="$tb elf32-xgate.lo elf32.lo $elf" ;;
>> diff --git a/bfd/configure.in b/bfd/configure.in index fc17209..a2b01a0
> 100644
>> --- a/bfd/configure.in
>> +++ b/bfd/configure.in
>> @@ -832,6 +832,7 @@ do
>>      bfd_elf32_v850_vec)              tb="$tb elf32-v850.lo elf32.lo $elf"
> ;;
>>      bfd_elf32_v850_rh850_vec)        tb="$tb elf32-v850.lo elf32.lo $elf"
> ;;
>>      bfd_elf32_vax_vec)               tb="$tb elf32-vax.lo elf32.lo $elf"
> ;;
>> +    bfd_elf32_unicore32_vec)         tb="$tb elf32-unicore32.lo elf32.lo
>> $elf" ;;
>>      bfd_elf32_xstormy16_vec) tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
>>      bfd_elf32_xc16x_vec)             tb="$tb elf32-xc16x.lo elf32.lo
> $elf" ;;
>>      bfd_elf32_xgate_vec)     tb="$tb elf32-xgate.lo elf32.lo $elf" ;;
>> diff --git a/bfd/cpu-unicore32.c b/bfd/cpu-unicore32.c index
> fe5ce32..9f3f5b8
>> 100644
>> --- a/bfd/cpu-unicore32.c
>> +++ b/bfd/cpu-unicore32.c
>> @@ -33,11 +33,12 @@ const bfd_arch_info_type bfd_unicore32_arch =
>>      "unicore32",           /* Arch name.  */
>>      "unicore32",           /* Printable name.  */
>>      2,                /* Unsigned int section alignment power.  */
>> -   /* TRUE if this is the default machine for the architecture.
>> -   The default arch should be the first entry for an arch so that
>> -   all the entries for that arch can be accessed via next. */
>> +    /* TRUE if this is the default machine for the architecture.
>> +       The default arch should be the first entry for an arch so that
>> +       all the entries for that arch can be accessed via next. */
> 格式调整?
嗯。根据大家之前的意见。
>
>>      TRUE,             /* The one and only.  */
>>      bfd_default_compatible,
>>      bfd_default_scan ,
>> -    0,
>> +    NULL,
>> +    NULL
>>    };
>> diff --git a/bfd/elf32-unicore32.c b/bfd/elf32-unicore32.c index
>> a02d05a..9df5c0e 100644
>> --- a/bfd/elf32-unicore32.c
>> +++ b/bfd/elf32-unicore32.c
>> @@ -11,6 +11,21 @@
>>  #include "libiberty.h"
>>
>>
>> +/* Stub */
>> +static reloc_howto_type *
>> +elf_unicore32_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
>> +                            bfd_reloc_code_real_type code
>> ATTRIBUTE_UNUSED) {
>> +    return NULL;
>> +}
>> +
>> +/* Stub */
>> +static reloc_howto_type *
>> +elf_unicore32_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
>> +                            const char *r_name ATTRIBUTE_UNUSED) {
>> +    return NULL;
>> +}
>> +
>>  #define ELF_ARCH                       bfd_arch_unicore32
>>  #define ELF_MACHINE_CODE               EM_UNICORE32
>>  #define ELF_MAXPAGESIZE                        0x1000
>> @@ -18,4 +33,7 @@
>>  #define TARGET_LITTLE_SYM              bfd_elf32_unicore32_vec
>>  #define TARGET_LITTLE_NAME             "elf32-unicore32"
>>
>> +#define bfd_elf32_bfd_reloc_type_lookup
>> elf_unicore32_reloc_type_lookup
>> +#define bfd_elf32_bfd_reloc_name_lookup
>> elf_unicore32_reloc_name_lookup
>> +
>>  #include "elf32-target.h"
>> diff --git a/include/elf/common.h b/include/elf/common.h index
>> 4399d02..72a4e85 100644
>> --- a/include/elf/common.h
>> +++ b/include/elf/common.h
>> @@ -406,7 +406,7 @@
>>  #define EM_ADAPTEVA_EPIPHANY   0x1223  /* Adapteva's Epiphany
>> architecture.  */
>>
>>  /* See the above comment before you add a new EM_* value here.  */
>> -
>> +#define EM_UNICORE32 0xed34
>
> 我们申请的号码是110(十进制),不知道这里是否要做调整?
Great!我把它改过来。
>
>
>>  /* Values for e_version.  */
>>
>>  #define EV_NONE              0               /* Invalid ELF version */
>> --
>> 1.8.1.1
>
>
>

另外,现在我又给gas和ld加上了一些stub,现在整个binutils已经可以build了,当然还是
完全不能用的。我现在在着手让gas支持一些简单的操作寄存器的指令,这样就不存在
重定位的问题。然后再慢慢支持更多的特性。

刘智猷

Other related posts:

  • » [linux-unicore] Re: [linux-unicore] 答复: [linux-unicore] [PATCH/binutils] Add definitions and stubs for building bfd. - 刘智猷