* How define absolute local symbol by GNU as?
@ 2011-07-07 14:25 Oleksandr Gavenko
2011-07-07 14:41 ` Andreas Schwab
0 siblings, 1 reply; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-07-07 14:25 UTC (permalink / raw)
To: binutils
To mark object file safe for SEH (to make .lib compatable with MSVC)
it is possible to define absolute local symbol with name '@feat.00'
and with value '1'.
I can achieve this by:
ASFLAGS += -Wa,"-defsym,@feat.00=1"
With GNU As language syntax I don't know how achieve this.
To make global symbol I use:
.global @feat.00
@feat.00=1
But how declare it local?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-07 14:25 How define absolute local symbol by GNU as? Oleksandr Gavenko
@ 2011-07-07 14:41 ` Andreas Schwab
2011-07-07 16:18 ` Oleksandr Gavenko
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-07-07 14:41 UTC (permalink / raw)
To: Oleksandr Gavenko; +Cc: binutils
Oleksandr Gavenko <gavenko@bifit.com.ua> writes:
> But how declare it local?
Don't declare it global.
Andreas.
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-07 14:41 ` Andreas Schwab
@ 2011-07-07 16:18 ` Oleksandr Gavenko
2011-07-07 16:30 ` Bob Plantz
2011-07-08 0:53 ` Andreas Schwab
0 siblings, 2 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-07-07 16:18 UTC (permalink / raw)
To: binutils
On 07.07.2011 17:25, Andreas Schwab wrote:
> Oleksandr Gavenko<gavenko@bifit.com.ua> writes:
>
>> But how declare it local?
>
> Don't declare it global.
>
OK, but how?
If I write:
.global @feat.00
@feat.00=1
I get:
$ nm test.obj | grep feat
00000001 A @feat.00
If I write:
/* .global @feat.00 */
@feat.00=1
I get:
$ nm test.obj | grep feat
<empty>
So I expect existence of some directive to get wanted.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-07 16:18 ` Oleksandr Gavenko
@ 2011-07-07 16:30 ` Bob Plantz
2011-07-08 0:53 ` Andreas Schwab
1 sibling, 0 replies; 9+ messages in thread
From: Bob Plantz @ 2011-07-07 16:30 UTC (permalink / raw)
To: Oleksandr Gavenko; +Cc: binutils
On 07/07/2011 07:40 AM, Oleksandr Gavenko wrote:
> On 07.07.2011 17:25, Andreas Schwab wrote:
>> Oleksandr Gavenko<gavenko@bifit.com.ua> writes:
>>
>>> But how declare it local?
>>
>> Don't declare it global.
>>
> OK, but how?
>
> If I write:
>
> .global @feat.00
> @feat.00=1
>
> I get:
>
> $ nm test.obj | grep feat
> 00000001 A @feat.00
>
> If I write:
>
> /* .global @feat.00 */
> @feat.00=1
>
> I get:
>
> $ nm test.obj | grep feat
> <empty>
>
> So I expect existence of some directive to get wanted.
One suggestion is to write what you want in C, then use gcc's -S option
to produce the assembly language, and look to see how gcc does it. For
example,
int y = 456;
int func() {
static int x = 123;
x = x + 1;
y = y + 1;
return x + y;
}
gives
.file "static.c"
.globl y
.data
.align 4
.type y, @object
.size y, 4
y:
.long 456
.text
.globl func
.type func, @function
func:On 07/07/2011 07:40 AM, Oleksandr Gavenko wrote:
> On 07.07.2011 17:25, Andreas Schwab wrote:
>> Oleksandr Gavenko<gavenko@bifit.com.ua> writes:
>>
>>> But how declare it local?
>>
>> Don't declare it global.
>>
> OK, but how?
>
> If I write:
>
> .global @feat.00
> @feat.00=1
>
> I get:
>
> $ nm test.obj | grep feat
> 00000001 A @feat.00
>
> If I write:
>
> /* .global @feat.00 */
> @feat.00=1
>
> I get:
>
> $ nm test.obj | grep feat
> <empty>
>
> So I expect existence of some directive to get wanted.
One suggestion is to write what you want in C, then use gcc's -S option
to produce the assembly language, and look to see how gcc does it. For
example,
int y = 456;
int func() {
static int x = 123;
x = x + 1;
y = y + 1;
return x + y;
}
gives
.file "static.c"
.globl y
.data
.align 4
.type y, @object
.size y, 4
y:
.long 456
.text
.globl func
.type func, @function
func:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
movq %rsp, %rbp
.cfi_offset 6, -16On 07/07/2011 07:40 AM, Oleksandr Gavenko wrote:
> On 07.07.2011 17:25, Andreas Schwab wrote:
>> Oleksandr Gavenko<gavenko@bifit.com.ua> writes:
>>
>>> But how declare it local?
>>
>> Don't declare it global.
>>
> OK, but how?
>
> If I write:
>
> .global @feat.00
> @feat.00=1
>
> I get:
>
> $ nm test.obj | grep feat
> 00000001 A @feat.00
>
> If I write:
>
> /* .global @feat.00 */
> @feat.00=1
>
> I get:
>
> $ nm test.obj | grep feat
> <empty>
>
> So I expect existence of some directive to get wanted.
One suggestion is to write what you want in C, then use gcc's -S option
to produce the assembly language, and look to see how gcc does it. For
example,
int y = 456;
int func() {
static int x = 123;
x = x + 1;
y = y + 1;
return x + y;
}
gives
.file "static.c"
.globl y
.data
.align 4
.type y, @object
.size y, 4
y:
.long 456
.text
.globl func
.type func, @function
func:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
movq %rsp, %rbp
.cfi_offset 6, -16
.cfi_def_cfa_register 6
movl x.1616(%rip), %eax
addl $1, %eax
movl %eax, x.1616(%rip)
movl y(%rip), %eax
addl $1, %eax
movl %eax, y(%rip)
movl x.1616(%rip), %edx
movl y(%rip), %eax
leal (%rdx,%rax), %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size func, .-func
.data
.align 4
.type x.1616, @object
.size x.1616, 4
x.1616:
.long 123
.ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
.section .note.GNU-stack,"",@progbits
.cfi_def_cfa_register 6
movl x.1616(%rip), %eax
addl $1, %eax
movl %eax, x.1616(%rip)
movl y(%rip), %eax
addl $1, %eax
movl %eax, y(%rip)
movl x.1616(%rip), %edx
movl y(%rip), %eax
leal (%rdx,%rax), %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size func, .-func
.data
.align 4
.type x.1616, @object
.size x.1616, 4
x.1616:
.long 123
.ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
.section .note.GNU-stack,"",@progbits
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
movq %rsp, %rbp
.cfi_offset 6, -16
.cfi_def_cfa_register 6
movl x.1616(%rip), %eax
addl $1, %eax
movl %eax, x.1616(%rip)
movl y(%rip), %eax
addl $1, %eax
movl %eax, y(%rip)
movl x.1616(%rip), %edx
movl y(%rip), %eax
leal (%rdx,%rax), %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size func, .-func
.data
.align 4
.type x.1616, @object
.size x.1616, 4
x.1616:
.long 123
.ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
.section .note.GNU-stack,"",@progbits
which causes me to believe that placing your variable in the .data
segment without a .global directive would give what you want.
--Bob
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-07 16:18 ` Oleksandr Gavenko
2011-07-07 16:30 ` Bob Plantz
@ 2011-07-08 0:53 ` Andreas Schwab
2011-07-08 12:44 ` Oleksandr Gavenko
1 sibling, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-07-08 0:53 UTC (permalink / raw)
To: Oleksandr Gavenko; +Cc: binutils
Works for me.
$ echo a=1 | as
$ nm
00000001 a a
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-08 0:53 ` Andreas Schwab
@ 2011-07-08 12:44 ` Oleksandr Gavenko
2011-07-08 20:28 ` Oleksandr Gavenko
2011-07-11 19:58 ` Oleksandr Gavenko
0 siblings, 2 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-07-08 12:44 UTC (permalink / raw)
To: binutils
On 07.07.2011 19:29, Andreas Schwab wrote:
> Works for me.
>
> $ echo a=1 | as
> $ nm
> 00000001 a a
>
I try on Linux and FreeBSD host and get similar result (GOOD).
But with Cygwin:
/usr/bin/as
/usr/bin/i686-pc-mingw32-as.exe
/usr/bin/i686-w64-mingw32-as.exe
with version:
GNU assembler (GNU Binutils) 2.20.51.20100410
GNU assembler (GNU Binutils) 2.21
GNU assembler (GNU Binutils) 2.21.51.20110605
$ echo a=1 | i686-pc-mingw32-as
$ nm
00000000 b .bss
00000000 d .data
00000000 t .text
I can not get same result. So this can be related to COFF format?
--keep-locals also have no effect.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-08 12:44 ` Oleksandr Gavenko
@ 2011-07-08 20:28 ` Oleksandr Gavenko
2011-07-11 19:58 ` Oleksandr Gavenko
1 sibling, 0 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-07-08 20:28 UTC (permalink / raw)
To: binutils
On 08.07.2011 11:47, Oleksandr Gavenko wrote:
> On 07.07.2011 19:29, Andreas Schwab wrote:
>> Works for me.
>>
>> $ echo a=1 | as
>> $ nm
>> 00000001 a a
>>
> I try on Linux and FreeBSD host and get similar result (GOOD).
>
> But with Cygwin:
>
> /usr/bin/as
> /usr/bin/i686-pc-mingw32-as.exe
> /usr/bin/i686-w64-mingw32-as.exe
>
> with version:
>
> GNU assembler (GNU Binutils) 2.20.51.20100410
> GNU assembler (GNU Binutils) 2.21
> GNU assembler (GNU Binutils) 2.21.51.20110605
>
> $ echo a=1 | i686-pc-mingw32-as
> $ nm
> 00000000 b .bss
> 00000000 d .data
> 00000000 t .text
>
> I can not get same result. So this can be related to COFF format?
>
> --keep-locals also have no effect.
I try another approach:
$ gcc -c -o test.o -Wa,"-defsym,my=1" test.c
$ objdump -t test.o
[ 2](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 my
To get same result I try write .s file:
.def my; .scl 3; .endef
then I get:
$ as -o test.o test.s; objdump -t test.o; nm test.o
[ 8](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 my
U my
Note: scl is 2, not 3!! With:
.def my; .scl 3; .val 1; .endef
$ as -o test.o test.s; objdump -t test.o; nm test.o
2.s: Assembler messages:
2.s:14: Internal error!
Assertion failure in coff_frob_symbol at
/netrel/src/binutils-2.20.51-2/gas/config/obj-coff.c line 1335.
Please report this bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-08 12:44 ` Oleksandr Gavenko
2011-07-08 20:28 ` Oleksandr Gavenko
@ 2011-07-11 19:58 ` Oleksandr Gavenko
2011-07-11 20:09 ` Oleksandr Gavenko
1 sibling, 1 reply; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-07-11 19:58 UTC (permalink / raw)
To: binutils
I repost my question as no one replay and my job SMTP server
in range of spam area of ISP (I think is just blocked).
On 08.07.2011 11:47, Oleksandr Gavenko wrote:
> On 07.07.2011 19:29, Andreas Schwab wrote:
>> Works for me.
>>
>> $ echo a=1 | as
>> $ nm
>> 00000001 a a
>>
> I try on Linux and FreeBSD host and get similar result (GOOD).
>
> But with Cygwin:
>
> /usr/bin/as
> /usr/bin/i686-pc-mingw32-as.exe
> /usr/bin/i686-w64-mingw32-as.exe
>
> with version:
>
> GNU assembler (GNU Binutils) 2.20.51.20100410
> GNU assembler (GNU Binutils) 2.21
> GNU assembler (GNU Binutils) 2.21.51.20110605
>
> $ echo a=1 | i686-pc-mingw32-as
> $ nm
> 00000000 b .bss
> 00000000 d .data
> 00000000 t .text
>
> I can not get same result. So this can be related to COFF format?
>
> --keep-locals also have no effect.
I try another approach:
$ gcc -c -o test.o -Wa,"-defsym,my=1" test.c
$ objdump -t test.o
[ 2](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 my
To get same result I try write .s file:
.def my; .scl 3; .endef
then I get:
$ as -o test.o test.s; objdump -t test.o; nm test.o
[ 8](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 my
U my
Note: scl is 2, not 3!! With:
.def my; .scl 3; .val 1; .endef
$ as -o test.o test.s; objdump -t test.o; nm test.o
2.s: Assembler messages:
2.s:14: Internal error!
Assertion failure in coff_frob_symbol at
/netrel/src/binutils-2.20.51-2/gas/config/obj-coff.c line 1335.
Please report this bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How define absolute local symbol by GNU as?
2011-07-11 19:58 ` Oleksandr Gavenko
@ 2011-07-11 20:09 ` Oleksandr Gavenko
0 siblings, 0 replies; 9+ messages in thread
From: Oleksandr Gavenko @ 2011-07-11 20:09 UTC (permalink / raw)
To: binutils
I repost my question as no one replay and my job SMTP server
in range of spam area of ISP (I think is just blocked).
On 08.07.2011 11:47, Oleksandr Gavenko wrote:
> On 07.07.2011 19:29, Andreas Schwab wrote:
>> Works for me.
>>
>> $ echo a=1 | as
>> $ nm
>> 00000001 a a
>>
> I try on Linux and FreeBSD host and get similar result (GOOD).
>
> But with Cygwin:
>
> /usr/bin/as
> /usr/bin/i686-pc-mingw32-as.exe
> /usr/bin/i686-w64-mingw32-as.exe
>
> with version:
>
> GNU assembler (GNU Binutils) 2.20.51.20100410
> GNU assembler (GNU Binutils) 2.21
> GNU assembler (GNU Binutils) 2.21.51.20110605
>
> $ echo a=1 | i686-pc-mingw32-as
> $ nm
> 00000000 b .bss
> 00000000 d .data
> 00000000 t .text
>
> I can not get same result. So this can be related to COFF format?
>
> --keep-locals also have no effect.
I try another approach:
$ gcc -c -o test.o -Wa,"-defsym,my=1" test.c
$ objdump -t test.o
[ 2](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 my
To get same result I try write .s file:
.def my; .scl 3; .endef
then I get:
$ as -o test.o test.s; objdump -t test.o; nm test.o
[ 8](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 my
U my
Note: scl is 2, not 3!! With:
.def my; .scl 3; .val 1; .endef
$ as -o test.o test.s; objdump -t test.o; nm test.o
2.s: Assembler messages:
2.s:14: Internal error!
Assertion failure in coff_frob_symbol at
/netrel/src/binutils-2.20.51-2/gas/config/obj-coff.c line 1335.
Please report this bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-07-11 19:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 14:25 How define absolute local symbol by GNU as? Oleksandr Gavenko
2011-07-07 14:41 ` Andreas Schwab
2011-07-07 16:18 ` Oleksandr Gavenko
2011-07-07 16:30 ` Bob Plantz
2011-07-08 0:53 ` Andreas Schwab
2011-07-08 12:44 ` Oleksandr Gavenko
2011-07-08 20:28 ` Oleksandr Gavenko
2011-07-11 19:58 ` Oleksandr Gavenko
2011-07-11 20:09 ` Oleksandr Gavenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).