APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > News Posts > compiling ssh gcc ––>Re: ssh 2.0.13 & illegal asms
Printer Friendly Version




News Group Posts

compiling ssh gcc


It is this kind of maddening minutia that can drive you nearly crazy when trying to port code.

If the expected roadblocks aren't enough, some esoteric thing like this will creep in and laugh silently while your efforts fail and fail again.


From: Robert Lipe <robertlipe@usa.net>
Newsgroups: comp.unix.sco.misc
Subject: Re: SCO and SSH(d)
Date: Sun, 19 Dec 1999 06:15:21 GMT
Message-ID: <s5otvpk5ee6159@corp.supernews.com> 

"Buddy Z" <diespammersdie-zed@wcs.ab.ca> writes:

>Anders Gulden Olstad <andersgo@alge.anart.no> wrote in message
>news:rpfa38.ut5.ln@jeeves.itte.net...
>> This has maybe been discussed before - but looking at the portability list
>> for SSH1, SCO Unix is listed as "client only".



sshd and ssh both work fine for me.   I use it daily.

>/usr/tmp/cca006wL.s:1594:invalid register for instruction: %edx in rolw
>/usr/tmp/cca006wL.s:1594:invalid register for instruction: %edx in rolw

The ssh source is broken when compiling with GCC and a strict assembler
such as OpenServer's native one or newer versions of GAS.  See attached
patch.


>From robertl@sco.com Sat Oct  2 04:21:25 1999
Date: Sat, 2 Oct 1999 04:21:25 -0500
From: Robert Lipe <robertl@sco.com>
Subject: Re: ssh 2.0.13 & illegal asms
Message-ID: <19991002042125.N25838@rjlhome.sco.com> 
Status: RO
Content-Length: 2793

Yesterday I submitted a patch to SSH 2.0.13.   Please replace it with
this one.





One of my peers who is much more the IA32 assembler wizard than myself
explained what these functions were trying to do and why my patch was
misguided.  He explained that they were just doing byteswapping.

> But neither is going to work right.  They're pulling a trick here which
> *requires* the assembler to do what SCO's fails to do: accept a size
> mismatch between opcode and operand.
> 
> They're trying to build code similar to:
> 
>                    //                   __byte__--byte--__byte__--byte--
>   movl (arg), %eax //             eax = wwwwwwwwxxxxxxxxyyyyyyyyzzzzzzzz
>   rolw    $8,  %ax // swap bytes: eax = wwwwwwwwxxxxxxxxzzzzzzzzyyyyyyyy
>   roll   $16, %eax // swap words: eax = zzzzzzzzyyyyyyyywwwwwwwwxxxxxxxx
>   rolw    $8,  %ax // swap bytes: eax = zzzzzzzzyyyyyyyyxxxxxxxxwwwwwwww
> 
> They definitely intend to manipulate only the low two bytes in
> instructions #2 and 4.
> 
> Unfortunately, this requires some textual manipulation of the argument
> "%0", and I don't know whether that's possible in the context of the C
> preprocessor + "__asm__" handling.  Their previous solution, now
> provoking warnings from GNU and failures from SCO, was to fudge it by
> spelling it "%eax" all the time; providing the size information in the
> opcode name; and hoping that the assembler would forgive the mismatch.

With that in mind, I believe thw following to be a better fix.   It adjusts
the constraints on the asm operands to more accurately reflect what we're
trying to do.


--- sshgetput.c_        Mon Feb  8 02:32:59 1999
+++ sshgetput.c Thu Sep 30 20:29:12 1999
@@ -47,7 +47,7 @@
 SshUInt32 SSH_GET_32BIT(const unsigned char *cp)                                {
   SshUInt32 result;
   -  __asm__ volatile ("movl (%1), %0; rolw $8, %0; roll $16, %0; rolw $8, %0;"

+  __asm__ volatile ("movl (%1), %0; rolw $8, %w0; roll $16, %0; rolw $8, %w0;"
           : "=&r" (result)
           : "r" (cp));    
   return result;
--- sshgetput.h_        Thu Sep 30 20:23:09 1999
+++ sshgetput.h Thu Sep 30 20:30:06 1999
@@ -181,7 +181,7 @@ 
 #define SSH_GET_32BIT(cp) \
 ({  \
   SshUInt32 __v__; \
-  __asm__ volatile ("movl (%1), %0; rolw $8, %0; roll $16, %0; rolw $8, %0;" \
+  __asm__ volatile ("movl (%1), %0; rolw $8, %w0; roll $16, %0; rolw $8, %w0;" \
           : "=&r" (__v__) \
           : "r" (cp)); \   
   __v__; \


Imposing the additional (word) constraint on the zero't argument does indeed
result in assembly code like this:

         movl (%edx), %eax; rolw $8, %ax; roll $16, %eax; rolw $8, %ax;


Thanx to the person that pointed this out.   Once I had that hint,
expressing it in GCC syntax wasn't too hard.

RJL


If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

Comments?




More Articles by Tony Lawrence - Find me on Google+



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!


book graphic unix and linux troubleshooting guide




 I sell and support
 Kerio Mail server
pavatar.jpg

This post tagged:

       - Compiler
       - Conversion
       - Programming
       - SCO_OSR5
       - Troubleshooting




Unix/Linux Consultants

Skills Tests

Guest Post Here