linux-mips
[Top] [All Lists]

Re: MIPS gas problem

To: ian@zembu.com
Subject: Re: MIPS gas problem
From: Hiroyuki Machida <machida@sm.sony.co.jp>
Date: Fri, 21 Apr 2000 12:30:14 +0900
Cc: kk@ddeorg.soft.net, binutils@sourceware.cygnus.com, linux@cthulhu.engr.sgi.com, debian-mips@lists.debian.org
In-reply-to: <20000420164812.17210.qmail@daffy.airs.com>
References: <200004201207.RAA07021@madras.ddeorg.soft.net> <20000420164812.17210.qmail@daffy.airs.com>
Sender: owner-linuxmips@oss.sgi.com
Hi Ian,

From: Ian Lance Taylor <ian@zembu.com>
Subject: Re: MIPS gas problem
Date: 20 Apr 2000 09:48:12 -0700

>    [~] gcc -c  rotest.c -o rotest.o
>    rotest.c:8: warning: alignment of `global1' is greater than maximum object 
>    file alignment. Using 8.

This message is a gcc issue, as you said. 

But, my reported plobelm is really binutils issue. Sorry to confuse
you. I will describe the problem using only asm file, again. 

Assmbling and linking attached al.S, I got the following result.

% cc -o al -save-temps al.S

% nm al.o | grep global
0000000000000400 R global1
0000000000001000 R global2
0000000000000000 R globalc

% nm al | grep global
0000000000400dc0 R global1
00000000004019c0 R global2
00000000004009c0 R globalc

Alignments of global1 and global2  in "al.o" looks good. But in "al" 
not.

% objdump -h al.o | grep rodata
  5 .rodata       00001010  0000000000000000  0000000000000000 00000250  2**4

% objdump -h al | grep rodata
  9 .rodata       00001010  00000000004009c0  00000000004009c0 000009c0  2**4


I think when ld gathers read only section, the alignment will be broken.
Because .rodata section alignment of al.o is not the maximum rodata
object's alignment value(in this case 2**12).

I tracked down and found that s_change_sec():gas/config/tc-mips.c
resets section alignment to 2**4. 
So, the maximum rodata object's alignment value will be lost in the
following sequence. 

        .rdata          // reset  section-alignment to 2**4
        .algin  10      // update section-alignment to 2**10
        .type    global1,@object;
        .size    global1,4;
global1:
        .word   0;

        .rdata          // reset  section-alignment to 2**4, Why??
        .align  2       // not update ( 2 <= current section-alignment)
string:
        .ascii  "test\n"
        

I want to know the reason why s_change_sec() always reset
section-alignment to 2**4. I think this is wrong.



--- al.S
        .abicalls

        .globl  globalc;
        .rdata;
        .type    globalc,@object;
        .size    globalc,1;
globalc:
        .byte   97;

// rodata aligned 10 (1024)
        .globl  global1;
        .align  10;
        .type    global1,@object;
        .size    global1,4;
global1:
        .word   0;

// rodata aligned 12 (4096)
        .globl  global2;
        .align  12;
        .type    global2,@object;
        .size    global2,4;
global2:
        .word   1;

// data
        .globl  total_ng
        .data
        .align  2
        .type    total_ng,@object
        .size    total_ng,4
total_ng:
        .word   0

// rodata again
        .rdata
        .align  2
string:
        .ascii  "test\n"
        .text
        .align  3
        .globl  main
        .ent    main
main:
        nop;
        nop
        nop
        .end main
--- endof al.S

---
Hiroyuki Machida
Creative Station                SCE Inc./Sony Corp.


<Prev in Thread] Current Thread [Next in Thread>