your change adds check for preemption outside of shared and call shared. In
the case of "non_shared", this does not make sense since preemption is
always in the context of dynamic objects.
Sun

On Fri, Nov 11, 2011 at 6:01 PM, 朱庆 <zqing1...@gmail.com> wrote:

> Hi all,
>
> Can gatekeeper help review for a fix for bug848?
> https://bugs.open64.net/show_bug.cgi?id=848
>
> Case:
> $cat timer.c
> #include <stdio.h>
> extern unsigned long long __attribute__((section(".data"))) jiffies_64;
> extern unsigned long volatile __attribute__((section(".data"))) jiffies;
> unsigned long volatile __attribute__((section(".data"))) jiffies=100;
> unsigned long long  jiffies_64 __attribute__((__aligned__((1 << (6))))) =
> ((unsigned long)(unsigned int) (-300*1000));
> void do_timer(unsigned long ticks)
> {
>        jiffies_64 += ticks;
> }
> int main()
> {
> do_timer(1);
> printf("%d\n", jiffies_64);
> printf("%d\n", jiffies);
> }
>
> $cat a.lds:
> iffies_64 = jiffies;
>
> The problem is when link with "a.lds", the output of open64 is wrong.
> The output of jiffies_64 and jiffies should be the same according to
> the linker script.
> opencc a.lds timer.c -O0 -keep
> ./a.out
> -299999
> 100
>
> when compile with gcc
> ./a.out
> 101
> 101
>
> The root reason is in open64, the preemitable symbol is addressed
> through base and offset.
> the output of timer.s:
>  #   3  extern unsigned long volatile __attribute__((section(".data")))
> jiffies;
>  #   4  unsigned long volatile __attribute__((section(".data")))
> jiffies=100;
>  #   5  unsigned long long  jiffies_64 __attribute__((__aligned__((1 <<
> (6)))))
> = ((unsigned long)(unsigned int) (-300*1000));
>  #   6  void do_timer(unsigned long ticks)
>  #   7  {
> .LBB1_do_timer:
>        pushq %rbp                      #
>        movq %rsp,%rbp                  #
>        addq $-32,%rsp                  #
>        movq %rdi,-16(%rbp)             # ticks
>        .loc    1       8       0
>  #   8          jiffies_64 += ticks;
>        movq -16(%rbp),%rdi             # ticks
>        movq .data(%rip),%rax           #
>        addq %rdi,%rax                  #
>        movq %rax,.data(%rip)           #
>        leave                           #
>        ret                             #
> .LDWend_do_timer:
>        .size do_timer, .LDWend_do_timer-do_timer
>
> symbol jiffies_64 is represent through .data(%rip), but not
>  jiffies_64(%rip),
> so when in the linker script reset the address of jiffies_64 does not work.
>
> The patch attached at bug848_1.patch.  There is a regression caused by
> bug848_1.patch, the case is:
>
> extern void abort (void);
>
> volatile int out = 1;
> volatile int a = 2;
> volatile int b = 4;
> volatile int c = 8;
> volatile int d = 16;
> volatile int e = 32;
> volatile int f = 64;
>
> int
> main ()
> {
>  asm volatile ("xorl %%eax, %%eax      \n\t"
>                "xorl %%esi, %%esi      \n\t"
>                "addl %1, %0            \n\t"
>                "addl %2, %0            \n\t"
>                "addl %3, %0            \n\t"
>                "addl %4, %0            \n\t"
>                "addl %5, %0            \n\t"
>                "addl %6, %0"
>                : "+r" (out)
>                : "r" (a), "r" (b), "r" (c), "g" (d), "g" (e), "g" (f)
>                : "%eax", "%esi");
>
>  if (out != 127)
>    abort ();
>
>  return 0;
> }
>
> The cause is that for asm string,  there is following code in fun
> "Modify_Asm_String":
>    ST* st = TN_var(tn);
>    Base_Symbol_And_Offset( st, &base_st, &base_ofst );
>  Base_Symbol_And_Offset does not consider whether shoud use
> base-offset or not. So I change the call to
> "Base_Symbol_And_Offset_For_Addressing". see bug848_2.patch
>
> Thanks
> zhuqing
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Open64-devel mailing list
> Open64-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/open64-devel
>
>
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to