centos7에서 32bit 코드 gcc 컴파일 질문입니다.

sac5의 이미지

선언부

  char buff[1024];
  char *result;
  char tmp_result[256];
  char buf_in[2048] ;

중간생략....
sprintf(buf_in,"<TITLE name='%s'>\n","model_info");
  printf("%s",buf_in);
  write(client_sockfd, buf_in, strlen(buf_in)+1);
  read (client_sockfd, NULL, 0);
 
  shell_cmd_group("Model","cat /proc/scsi/scsi |grep -m1 Vendor |awk -F' ' '{print $2,$4}'",client_sockfd);
 
  sprintf(buf_in,"%s \n\n","</TITLE>");
  write(client_sockfd, buf_in, strlen(buf_in)+1);
  read (client_sockfd, NULL, 0);
  printf("%s",buf_in);  

코드는 일부입니다. 대부분 공통적으로 들어가는 부분만 ..
centos6(32bit)에서는 정상적으로 동작합니다만..
centos7(64bit) 환경에서 gcc 32bit 컴파일 환경을 만들어서 컴파일 할경우 컴파일도 정상적으로 되고 실행도 되지만 글씨가 전부 짤립니다.

(gcc 컴파일시 werror 도 모두 체크하고 수정했지만 동일하게..)

Necromancer의 이미지

컴파일, 링크할때 -m32 옵션 넣었나요?

32비트 환경 만들었다 해도 안넣으면 64비트로 컴파일될꺼고 그런경우 포인터형들이 크기가 달라지니 그것과 관련된 문제가 생길 수 있습니다.

Written By the Black Knight of Destruction

sac5의 이미지

-m32도 넣었습니다.
결과는 동일한 것 같습니다.

Necromancer의 이미지

그렇다면 지금 올려주신 정보만으로는 판단이 안됩니다.
하나하나 추적해야 할 것 같습니다.

Written By the Black Knight of Destruction

sac5의 이미지

recv(client_sockfd,NULL,0,0);
32비트 상에서는 위와 같이 되어있던 부분을 아래로 바꿨습니다. ( 64bit에서는 이부분이 있으면 아에 동작을 안해서 )

read (client_sockfd, NULL, 0);

twinwings의 이미지

read는 일반적인 FD가 제공하는 인터페이스이고,

recv는 Socket에 한정된 FD가 제공하는 인터페이스입니다.

https://wiki.linuxfoundation.org/images/1/1c/Network_data_flow_through_kernel.png

제가 알기론, recv 내부적으로 결국 (가상함수가 바인딩 되어있는)

read를 호출하는 걸로 알고 있습니다.

왜 문제 생기는지는 우선 perror() 등으로 찍어봐야 할 것 같으나

read/recv 때문은 아닐 지도 모르겠다라는 생각이 듭니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.