If you are using libc for malloc then using pragma requires recompilation of libc. So even if you use the pragma in openssl it will not force the alignment in libc. Correct me if my understanding of what you meant was wrong.
In case if you use glibc, here is something that may be of use to you. Glibc uses alignment of the size of double. It is hard coded. So you have to change the code and recompile glibc for your use. As size of double is generally a multiple of 2 bytes in most places you may not need any recompilation. Check it out here: http://www.itborder.com/SOFTWARE/linux/gnu/glibc-2.3.2/glibc-2.3.2/elf/dl-minimal.c reg JB On 7/4/05, Riaz Farnaz <[EMAIL PROTECTED]> wrote: > Malloc doesnt guarantee an alignment of any sort. ASIC chip requres that the > buffer address that is passed to it should be a strictly 16 bit ( not byte ) > aligned...I was going thru this link > http://sources.redhat.com/ml/crossgcc/2000-08/msg00049.html > and here he has suggested a method of defining > > #define HANDLE_PRAGMA_PACK_PUSH_POP 1 rebuild the compiler and > > use #pragma pack(push,<2>) for 2 byte ( which I believe is 16 bit alignment > ) alignment. So basically I think i can create a macro for the openssl > malloc function to > > { > #pragma pack(push,<2>) > malloc(....) > } > > I am not sure if this will work, this is mainly for gcc compiler, so this is > a compiler dependent solution. I have to yet check this. > > > On 7/4/05, Steven Reddie <[EMAIL PROTECTED]> wrote: > > > > Riaz, I think I misread/misunderstood your question. OpenSSL uses malloc > to allocate memory. malloc should return an allocated buffer which is > aligned appropriately for the underlying platform. Typically this alignment > will be greater than you require, such as to a 16-byte boundary. > > > > ________________________________ > From: [EMAIL PROTECTED] [mailto: > [EMAIL PROTECTED] On Behalf Of Steven Reddie > > Sent: Monday, 4 July 2005 4:23 PM > > To: openssl-users@openssl.org > > Subject: RE: does openssl allocate memory with 16 bit alignment? > > > > > > > > > > Isn't this the job of the compiler? > > > > I don't believe that OpenSSL goes out of it's way to access values larger > than 8-bits on unaligned addresses. One exception is the hand-optimised > crypto routines, such as AES, where 32-bit values may be accessed on > arbitrary addresses. Check out the macros in aes_locl.h for examples of > handling this properly for processors that require it. Typical RISC > processors are more restrictive than what you're asking for, eg. expecting > 32-bit values to be aligned to 32-bit addresses, and these are definitely > supported by OpenSSL. The ARM processor is one example. I did the port for > this (for Windows CE) and ran into this problem with the AES module. If you > search for use of the OPENSSL_SYS_WINCE macro which I added to aes_locl.h > you may find other places where this was necessary, which I've now > forgotten. > > > > Your compiler should be generating code that packs structures > appropriately for the target processor. Except for the optimisations > mentioned above, OpenSSL simply accesses the fields within the structure, so > it's the job of the compiler to ensure that they are aligned appropriately. > And it's the job of the runtime system to ensure that the memory is > allocated on an appropriate boundary (typically a 16-byte boundary). > > > > Regards, > > > > Steven > > > > > > ________________________________ > From: [EMAIL PROTECTED] [mailto: > [EMAIL PROTECTED] On Behalf Of Riaz Farnaz > > Sent: Monday, 4 July 2005 4:04 PM > > To: openssl-users@openssl.org > > Subject: does openssl allocate memory with 16 bit alignment? > > > > > > > > Hi, > > > > I am working on a proprietary ASIC chip that requires the memory > buffers passed to it to be 16 bit aligned. Does Openssl support 16-bit > alignment of the memory being allocated or is there any way that I can force > 16 bit alignment of the data? > > > > -Riaz > > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]