Re: [x86-64 psABI] RFC: Extend x86-64 PLT entry to support MPX

2013-08-08 Thread Jan Beulich
>>> On 08.08.13 at 02:33, "H.J. Lu"  wrote:
> We use the .gnu_attribute directive to record an object attribute:
> 
> enum
> {
>   Tag_GNU_X86_EXTERN_BRANCH = 4,
> };
> 
> for the types of external branch instructions in relocatable files.
> 
> enum
> {
>   /* All external branch instructions are legacy.  */
>   Val_GNU_X86_EXTERN_BRANCH_LEGACY = 0,
>   /* There is at lease one external branch instruction with BND prefix.  */
>   Val_GNU_X86_EXTERN_BRANCH_BND = 1,
> };
> 
> An x86 feature note section, .note.x86-feature, is used to indicate
> features in executables and shared library. The contents of this note
> section are:
> 
> .section.note.x86-feature
> .align  4
> .long   .L1 - .L0
> .long   .L3 - .L2
> .long   1
> .L0:
> .asciz "x86 feature"
> .L1:
> .align  4
> .L2:
> .longFeatureFlag (Feature flag)
> .L3:
> 
> The current valid bits in FeatureFlag are
> 
> #define NT_X86_FEATURE_PLT_BND(0x1 << 0)
> 
> It should be set if PLT entry has BND prefix to preserve bound registers.
> 
> The remaining bits in FeatureFlag are reserved.
> 
> When merging Tag_GNU_X86_EXTERN_BRANCH, if any input relocatable
> file has Tag_GNU_X86_EXTERN_BRANCH set to Val_GNU_X86_EXTERN_BRANCH_BND,
> the resulting Tag_GNU_X86_EXTERN_BRANCH value should be
> Val_GNU_X86_EXTERN_BRANCH_BND.
> 
> When generating executable or shared library, if PLT is needed and
> Tag_GNU_X86_EXTERN_BRANCH value is Val_GNU_X86_EXTERN_BRANCH_BND,
> the 32-byte PLT entry should be used and the feature note section should
> be generated with the NT_X86_FEATURE_PLT_BND bit set to 1 and the feature
> note section should be included in PT_NOTE segment. The benefit of the
> note section is it is backward compatible with existing run-time and tools.

While I can see the purpose of the attribute section, I don't see
what the note section is for: You don't mention at all what it's
consumed for, and I also can't see how it validly would be for
anything. That's because iirc note section contents, if not
understood by the consumer, is required to not have any effect
on the correctness of the program. Hence if loaded on a system
that MPX capable, has an MPX aware kernel, but no MPX aware
user space (apart from this one executable or shared library, or
a set thereof), it ought to still work correctly. Which - afaict - it
won't if the dynamic loader itself isn't MPX aware.

Jan



__ARM_ARCH_2__

2013-08-08 Thread zhaobin xv
Hi

In linux/arch/arm/boot/
compressed/head.S:


#ifndef __ARM_ARCH_2__
/*
 * Booting from Angel - need to enter SVC mode and disable
 * FIQs/IRQs (numeric definitions from angel arm.h source).
 * We only do this if we were in user mode on entry.
 */
mrsr2, cpsr@ get current mode
tstr2, #3@ not user?
bnenot_angel
movr0, #0x17@ angel_SWIreason_EnterSVC
swi0x123456@ angel_SWI_ARM


I don't know what the"__ARM_ARCH_2__" mean?
"__ARM_ARCH_2__" is definded by gcc or definded byarmlinux?
where does it come from? what does it want to do?


Building Testing and Installing gcc-4.7.2

2013-08-08 Thread Ellis N. Thomas

Summary of Building Testing and Installing gcc-4.7.2

To:  gcc@gcc.gnu.org

1 Introduction

Built gcc-4.7.2.  Sending information because other builds seen
for Mac OS X did not include Ada (Gnat).

Report from configure etc.

bash> config.guess
i386-apple-darwin9.8.0

bash> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.7.2/usr/local/bin/../libexec/gcc/ 
i386-apple-darwin9.8.0/4.7.2/lto-wrapper

Target: i386-apple-darwin9.8.0
Configured with: ../src/gcc-4.7.2/configure --enable-languages=ada,c,c++
Thread model: posix
gcc version 4.7.2 (GCC)


Running Mac OS X:

 System Version:Mac OS X 10.5.8 (9L30)
 Kernel Version:Darwin 9.8.0
bash> uname -mpv
 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009;  
root:xnu-1228.15.4~1/RELEASE_I386 i386 i386



2 Problems Encountered

During the build, test, and install operations, several problems
needed circumvention.  These are listed (with any work-around) in the  
next

sections.  In some cases bugs have been logged.

2.1 Prerequisites

Problem: Latest GMP, MPFR and MPC libraries (gmp-5.1.0a, mpc-1.0.1,  
mpfr-3.1.1)

led to failure in build stage 1.

Work-around: Use the versions listed in srcdir/contrib/ 
download_prerequisites:

gmp-4.3.2, mpfr-2.4.2, mpc-0.8.1
The GCC install/prerequisites page specified:
GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
MPFR Library version 2.4.2 (or later)
MPC Library version 0.8.1 (or later)
even though configure recommended:
Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+

Bug Report: Bug 57087 - make failed: libmpfr not found or uses a  
different ABI



2.2 Failure in build stages 2 and 3 concerning pseudo-op: .balign

Problem: Failed in stages 2 and 3 for libcpp, "Unknown pseudo- 
op: .balign".


Work-around: After the failure in stage 2, modify objdir/libcpp/ 
config.h to

change HAVE_SSE4 to undef.  "#undef HAVE_SSE4"
Similarly, after the same failure in stage 3 make the same change (the
previously changed file is now in objdir/prev-libcpp/)

Bug Report: Bug 57291 - Failure in build stages 2 and 3 concerning
pseudo-op: .balign


2.3 Failures during "Build runtime libraries using the stage3 compiler  
from the

previous step."

Problem: Failed with errors for libitm.la:
"file is not of required architecture" and
"pointer in read-only segment not allowed"

Work-around: None.  However, a reply from gcc-help indicated:
"It sounds like everything is working but libitm."

Bug Report: Bug 57292 - Failure in build after stage 3, concerning  
libitm.la



2.4 Failures during testing

Problem: Testing of libitm failed, but this was expected.
=== libitm Summary ===

# of expected passes1
# of unexpected failures14
# of unresolved testcases   14
# of unsupported tests  1

Also testing of Ada (gnat) failed, with messages in the parts of the
logs concerning acats, including:

i686-apple-darwin9-gcc-4.0.1: language ada not recognized
 Failed to compile macrosub
Generating support files...fatal error, run-time library not installed  
correctly

cannot locate file system.ads
gnatmake: *** make failed.
 Failed to compile macrosub

Work-around: Ensure that the existing Ada compiler (used during the  
stage 1

build) remains available during testing of stage 3.
The "Installing GCC" information indicates the need for Prerequisites:
"In order to build the Ada compiler (GNAT) you must already have GNAT
installed because portions of the Ada frontend are written in Ada".
However, there is nothing to say that an existing Ada compiler is also
needed for testing.
Consequently, although /usr/local/ada-4.3/bin/ was made available in
the PATH used at build time, it was not added for testing.  It was
assumed that testing the as yet uninstalled compilation system would be
self-contained.

Bug Report: Bug 57606 - Failure in testing stage 3 of gcc-4.7.2


2.5 Failures during make install

Problem: Failed with errors for libitm.la, equivalent to the failures  
during

build runtime libraries.
In addition, the std output plus std error that was directed to a log
file contained 124 messages like.
ranlib: file: /usr/local/gcc-4.7.2/gcc/i386-apple-darwin9.8.0/4.7.2/ 
adalib/libgnarl.a(g-tastus.o) has no symbols


Work-around: None for libitm.
There were also "has no symbols" messages in the logs from make during
building.  It is assumed that these can be ignored, but there has been
no confirmation that this is correct from the gcc-h...@gcc.gnu.org
mailing list.

Bug Report: Bug 57292 - comment added concerning libitm


2.6 Problems with documentation

Problem: "make html’ was used to generate HTML for the gcc manual

load reverse

2013-08-08 Thread sravan megan
Hi All,

   I am new to GCC. I was working in an Embedded processor with
GCC-4.6.4 version.

   I need to add load/store reverse instructions to the MD file.

   My instructions will look as below:

   LWX Rd,Ra,Rb

operation: Addr := Ra + Rb
Rd := *Addr(loading data with the opposite endianness)

  SWX Rd,Ra,Rb

 operation: Addr := Ra + Rb
*Addr := Rd(storing data with the opposite endianness)



To add the above instructions in to md file I tried below pattern in md file

 (define_insn "movsi_rev"
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,m")
(bswap: SI (match_operand:SI 1 "move_src_operand" "m,d")))]
  ""
  "@
   lwx\t%0,%1,%0
   swx\t%0,%1,%0"
  [(set_attr "type" "load,store")
  (set_attr "mode"  "SI")
  (set_attr "length""4,4")])


   I wrote a small testcase which is generating swx instruction but
the operands are more due to which it is failing in assembler phase

ex:
int store_rev(int *n)
{
  return *n) & 0xff00) >> 24)
| (((*n) & 0x00ff) >>  8)
| (((*n) & 0xff00) <<  8)
| (((*n) & 0x00ff) << 24));

}

for the above store_rev function I need to generate only single swx instruction.
I was successful in generating the swx instruction but instead of 3
registers compiler is generating one extra operand "0"  swx r0,r2,0,r0

   ex: instead of swx r0,r2,r0 it is generating swx r0,r2,0,r0

can anyone please help me in removing the extra operand in the above
instruction.

Thanks,
Sravan


Re: __ARM_ARCH_2__

2013-08-08 Thread Richard Earnshaw
On 08/08/13 08:20, zhaobin xv wrote:
> Hi
> 
> In linux/arch/arm/boot/
> compressed/head.S:
> 
> 
> #ifndef __ARM_ARCH_2__
> /*
>  * Booting from Angel - need to enter SVC mode and disable
>  * FIQs/IRQs (numeric definitions from angel arm.h source).
>  * We only do this if we were in user mode on entry.
>  */
> mrsr2, cpsr@ get current mode
> tstr2, #3@ not user?
> bnenot_angel
> movr0, #0x17@ angel_SWIreason_EnterSVC
> swi0x123456@ angel_SWI_ARM
> 
> 
> I don't know what the"__ARM_ARCH_2__" mean?
> "__ARM_ARCH_2__" is definded by gcc or definded byarmlinux?
> where does it come from? what does it want to do?
> 
> 
> 

__ARM_ARCH_2__ is defined by GCC when compiling for an ARM cpu that
implements the ARMv2 revision of the architecture.  ARMv2 is now
obsolete and you'll almost certainly not want to support that now.

R.



Re: [x86-64 psABI] RFC: Extend x86-64 PLT entry to support MPX

2013-08-08 Thread H.J. Lu
On Thu, Aug 8, 2013 at 12:19 AM, Jan Beulich  wrote:
 On 08.08.13 at 02:33, "H.J. Lu"  wrote:
>> We use the .gnu_attribute directive to record an object attribute:
>>
>> enum
>> {
>>   Tag_GNU_X86_EXTERN_BRANCH = 4,
>> };
>>
>> for the types of external branch instructions in relocatable files.
>>
>> enum
>> {
>>   /* All external branch instructions are legacy.  */
>>   Val_GNU_X86_EXTERN_BRANCH_LEGACY = 0,
>>   /* There is at lease one external branch instruction with BND prefix.  */
>>   Val_GNU_X86_EXTERN_BRANCH_BND = 1,
>> };
>>
>> An x86 feature note section, .note.x86-feature, is used to indicate
>> features in executables and shared library. The contents of this note
>> section are:
>>
>> .section.note.x86-feature
>> .align  4
>> .long   .L1 - .L0
>> .long   .L3 - .L2
>> .long   1
>> .L0:
>> .asciz "x86 feature"
>> .L1:
>> .align  4
>> .L2:
>> .longFeatureFlag (Feature flag)
>> .L3:
>>
>> The current valid bits in FeatureFlag are
>>
>> #define NT_X86_FEATURE_PLT_BND(0x1 << 0)
>>
>> It should be set if PLT entry has BND prefix to preserve bound registers.
>>
>> The remaining bits in FeatureFlag are reserved.
>>
>> When merging Tag_GNU_X86_EXTERN_BRANCH, if any input relocatable
>> file has Tag_GNU_X86_EXTERN_BRANCH set to Val_GNU_X86_EXTERN_BRANCH_BND,
>> the resulting Tag_GNU_X86_EXTERN_BRANCH value should be
>> Val_GNU_X86_EXTERN_BRANCH_BND.
>>
>> When generating executable or shared library, if PLT is needed and
>> Tag_GNU_X86_EXTERN_BRANCH value is Val_GNU_X86_EXTERN_BRANCH_BND,
>> the 32-byte PLT entry should be used and the feature note section should
>> be generated with the NT_X86_FEATURE_PLT_BND bit set to 1 and the feature
>> note section should be included in PT_NOTE segment. The benefit of the
>> note section is it is backward compatible with existing run-time and tools.
>
> While I can see the purpose of the attribute section, I don't see
> what the note section is for: You don't mention at all what it's
> consumed for, and I also can't see how it validly would be for
> anything. That's because iirc note section contents, if not
> understood by the consumer, is required to not have any effect
> on the correctness of the program. Hence if loaded on a system
> that MPX capable, has an MPX aware kernel, but no MPX aware
> user space (apart from this one executable or shared library, or
> a set thereof), it ought to still work correctly. Which - afaict - it
> won't if the dynamic loader itself isn't MPX aware.
>

The note section isn't required for correctness.  But it can be used
by ld.so to select an alternate MPX aware shared library in a different
directory, instead of a legacy one.

There is another way to encode this information in the first entry
of PLT:

   0:ff 35 00 00 00 00pushq  GOT+8(%rip)
   6:f2 ff 25 00 00 00 00 bnd jmpq *GOT+16(%rip)
   d:0f 1f 44 00 00   nopl   0x0(%rax,%rax,1)
  12:0f 1f 80 00 00 00 00 nopl   0x0(%rax)
  19:0f 1f 80 00 00 00 01 nopl   0x100(%rax)

We can encode PLT property in 10 (4 + 4 + 2) bytes of
displacements of 3 nops.  In this example, the first bit
of the last byte of PLT0 is 1.

-- 
H.J.


__ARM_arch___

2013-08-08 Thread zhaobin xv
I want to find a manual about preprocessor mecro include __ARM_arch___


Re: __ARM_arch___

2013-08-08 Thread Jonathan Wakely
On 8 August 2013 17:03, zhaobin xv wrote:
> I want to find a manual about preprocessor mecro include __ARM_arch___

Please don't cross-post to the gcc and gcc-help lists, just pick one.

Your question is appropriate for the gcc-help list, please take any
follow-up there.


gcc-4.8-20130808 is now available

2013-08-08 Thread gccadmin
Snapshot gcc-4.8-20130808 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/4.8-20130808/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 4.8 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch 
revision 201611

You'll find:

 gcc-4.8-20130808.tar.bz2 Complete GCC

  MD5=41c22364d7a221e5b9be5c3549463720
  SHA1=826d1ee32780dc3ea9dadbaf5e0f7714c07e5e2a

Diffs from 4.8-20130801 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-4.8
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.