This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with gas "Error: attempt to .org backwards ignored"


Hello, Nick,

	Thanks for your kind help. I got some clue what is wrong. But I 
still need some more explanation so that I can hack my compiler to 
generate .s file that behaves.

	Basically, I modified my compiler to insert one new variable: 
SpLiTtEd_return_flag_callee_183. It might be used in the entire project 
(i.e. it is a global variable and it should be created only once).

	I admit that I don't understand well what properties the new 
symbol should be assigned so that its behavior meet my expection:

	When I create a symbol in my compiler, there are two kind of 
properties should be assigned:

(1) storage class
    
enum ST_SCLASS
{
    // the values should not overlap with those in ST_CLASS for error 
checking
    SCLASS_UNKNOWN	= 0,
    SCLASS_AUTO		= 1,		// stack variable
    SCLASS_FORMAL	= 2,		// formal parameter
    SCLASS_FORMAL_REF	= 3,		// reference parameter
    SCLASS_PSTATIC	= 4,		// PU scope static data
    SCLASS_FSTATIC	= 5,		// file scope static data
    SCLASS_COMMON	= 6,		// common block (linker allocated)
    SCLASS_EXTERN	= 7,		// unallocated external data or 
text
    SCLASS_UGLOBAL	= 8,		// uninitialized global data
    SCLASS_DGLOBAL	= 9,		// initialized global data
    SCLASS_TEXT		= 10,		// executable code
    SCLASS_REG		= 11,		// register variable
    SCLASS_CPLINIT	= 12,		// cplinit
    SCLASS_EH_REGION	= 13,		// eh region
    SCLASS_EH_REGION_SUPP = 14,		// eh region supp
    SCLASS_DISTR_ARRAY	= 15,		// distributed array
    SCLASS_COMMENT	= 16,		// comment section
    SCLASS_THREAD_PRIVATE_FUNCS	= 17, // thread-private constr/destr funcs
    SCLASS_COUNT	= 18		// total number of classes

}


(2) export scope

    enum ST_EXPORT
{
    EXPORT_LOCAL	= 0,		// Not exported, e.g. C static
    EXPORT_LOCAL_INTERNAL = 1,		// Statics that do not have 
address
					// passed outside of a.out/DSO. 
    EXPORT_INTERNAL	= 2,		// Exported, only visible and used
					// within the containing
					// DSO/executable, i.e. not even
					// passed outside using a pointer.  
    EXPORT_HIDDEN	= 3,		// Exported, but name is hidden
					// within the containing
					// DSO/executable.  However, the
					// address may be exported from 
the
					// DSO via a pointer.  
    EXPORT_PROTECTED	= 4,		// Exported from DSO, but
					// non-preemptible. 
    EXPORT_PREEMPTIBLE	= 5,		// Exported and preemptible.
    EXPORT_OPTIONAL	= 6,		// STO_OPTIONAL case in 
"sys/elf.h"
    EXPORT_COUNT	= 7		// Must be last for consistency
					// checking 
}


currently, I assigned them SCLASS_FSTATIC and EXPORT_LOCAL. The root of my 
problem is that I am not sure which one of them should REALLY be assigned. 
Can you explain me about it or guide me the correct materails to read 
about them? 
I think maybe I should assign them SCLASS_UGLOBAL and EXPORT_LOCAL. AM I looking 
at the real culprit? Or they don't matter and it only depends on the 
emission of the compiler backend?
Thanks a lot.

						Peng



On Mon, 15 Dec 2003, Nick Clifton wrote:

> Hi Peng,
> 
> >      I met a problem with gas when I do "as draw7.s -o draw7.o":
> >
> > draw7.s: Assembler messages:
> > draw7.s:11384: Error: attempt to .org backwards ignored
> >
> >      I don't know what is wrong with my .s file. Any hint? Thanks.
> 
> > I tried two versions of gas, both of them spit the above error messages.
> > (1) GNU assembler version 2.9-ia64-000717 (ia64-hp-linux) using BFD 
> > version 2.9-ia64-000717
> > (2) GNU assembler version 2.11.90.0.8 (ia64-redhat-linux) using BFD 
> > version 2.11.90.0.8
> 
> Both of these versions are very old.  I would recommend that you
> update your sources to the latest release (2.14) and then rebuild and
> reinstall the assembler.  This will not actually solve your problem,
> but it is likely to prevent you from running into other bugs.
> 
> The error message is occurring because you are trying to use the .org
> directive to move the location pointer inside the .sbss section
> backwards.  What is happening is this:
> 
> At line 3716 you have these lines:
> 
> 	.section .sbss
> 	.org 0x20
> 	.align	0
> 	.type	SpLiTtEd_return_flag_callee_183, @object
> 	.size	SpLiTtEd_return_flag_callee_183, 4
>   SpLiTtEd_return_flag_callee_183:	// 0x20
> 	.skip 4
> 
> This is the first declaration of an object inside the .sbss section
> and it ends up leaving the location pointer at 0x28.  Then at line
> 11383, (the first of the errors), you have these lines:
> 
> 	.section .sbss
> 	.org 0x0
> 	.align	0
> 	.type	LinkField0_49_24, @object
> 	.size	LinkField0_49_24, 8
>   LinkField0_49_24:	// 0x0
> 
> Obviously the intent of this code is to move back to the start of the
> .sbss section and insert the "LinkField0_49_24" label and its
> contents.  GAS does not allow this however.  It is a single pass
> assembler and so it does not allow the location pointer to be moved
> backwards.  (Please see the assembler documentation for more
> information about this).
> 
> The solution is to reorder your assembler code so that all of the
> contents of the .sbss section are declared in a linear order.  ie, if
> you change the lines at 3716 to look like this:
> 
> 	.section .sbss
> 	.org 0x0
> 	.align	0
> 	.type	LinkField0_49_24, @object
> 	.size	LinkField0_49_24, 8
>   LinkField0_49_24:	// 0x0
> 	.org 0x8
> 	.align	0
> 	.type	LinkField1_49_25, @object
> 	.size	LinkField1_49_25, 8
>   LinkField1_49_25:	// 0x8
> 	.org 0x10
> 	.align	0
> 	.type	LinkField2_49_26, @object
> 	.size	LinkField2_49_26, 8
>   LinkField2_49_26:	// 0x10
> 	.org 0x18
> 	.align	0
> 	.type	Query0_49_23, @object
> 	.size	Query0_49_23, 8
>   Query0_49_23:	// 0x18
> 	.org 0x20
> 	.align	0
> 	.type	SpLiTtEd_return_flag_callee_183, @object
> 	.size	SpLiTtEd_return_flag_callee_183, 4
>   SpLiTtEd_return_flag_callee_183:	// 0x20
> 	.skip 4
> 
> and the delete the lines at 11383 your program will assemble.
> 
> Cheers
>         Nick
> 
> ## RF rules: Init ORTInit Temp OK
> 

-- 
                         	            |    |    |
Peng Zhao                                  )_)  )_)  )_)
http://www.cs.ualberta.ca/~pengzhao       )___))___))___)
Phone: 1-780-492-3725	    		 )____)____)_____)\\
Fax:   1-780-492-1071	            ________|____|____|____\\\__
Lab:   CSC-251			-------\                   /---------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]