From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114844 invoked by alias); 21 May 2018 04:32:57 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 114832 invoked by uid 89); 21 May 2018 04:32:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=61, 71, 56, trampoline X-HELO: mail-qt0-f172.google.com Received: from mail-qt0-f172.google.com (HELO mail-qt0-f172.google.com) (209.85.216.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 May 2018 04:32:53 +0000 Received: by mail-qt0-f172.google.com with SMTP id j42-v6so17421428qtj.12 for ; Sun, 20 May 2018 21:32:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=13UP54a8EwrhE/nYlyBkpWg01YuE3msrFrDZvzCQw5Q=; b=j/xL/BRi+J3CVholthzDzqIvVjb9qyY9EvFTGvWtNN7xFIyUT0j1C0SPlW1dOBIk89 bWclByULfUh2AaJ4+3A3ijdUqAWRh/4dVXOrGmh0A2TdkGgfRbSDqoTVmzisQOLQiBMz RVkJbKZMUCnNi5CAq6CO5F0LGej3Xw8ispVwixmWKvC5AVKm02s6BqLIob1zGSH6xQOG eTElCSt0LmF7ZduMlGvZGEFYyEzyY40GJyJIh1Gha3OMzGPqlw05r/edig3MKrVC67eJ JpMWWVNGWz6qd/UJijs488+sVGFZah0d2lNQ502kJ/m8S1HH1DRjRzfmAAGH3xJkapII qgpQ== X-Gm-Message-State: ALKqPweYiHkZ6vZ0KJO1+dESuoS0Se+MZvZFpUhy7dvUaPCl+otX56lM 9jhggaIgSxnVfKb2eshgLMQ2NG7V6sPJvSmc5nU/QvF4 X-Google-Smtp-Source: AB8JxZoQDMrYGF0cViusU6gJpApWh0Fuj4AG3HZwERkXDMy1OAFe4tPkuplh8FH4qTr74oOxa11yqZzAxJ7o+haQPoA= X-Received: by 2002:ac8:4245:: with SMTP id r5-v6mr17127743qtm.262.1526877171544; Sun, 20 May 2018 21:32:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.232.13 with HTTP; Sun, 20 May 2018 21:32:51 -0700 (PDT) From: Remus Clearwater Date: Mon, 21 May 2018 04:32:00 -0000 Message-ID: Subject: Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c To: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00021.txt.bz2 https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86_64/makecontext.c;h=0d0802bf431326f7fcfe03d49df0c8ee7f4fdaab;hb=HEAD#l71 51 void 52 __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) 53 { 54 extern void __start_context (void) attribute_hidden; 55 greg_t *sp; 56 unsigned int idx_uc_link; 57 va_list ap; 58 int i; 59 60 /* Generate room on stack for parameter if needed and uc_link. */ 61 sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp 62 + ucp->uc_stack.ss_size); 63 sp -= (argc > 6 ? argc - 6 : 0) + 1; 64 /* Align stack and make space for trampoline address. */ 65 sp = (greg_t *) ((((uintptr_t) sp) & -16L) - 8); 66 67 idx_uc_link = (argc > 6 ? argc - 6 : 0) + 1; 68 69 /* Setup context ucp. */ 70 /* Address to jump to. */ 71 ucp->uc_mcontext.gregs[REG_RIP] = (uintptr_t) func; As far as I know cast a function pointer to ordinary integer type or void*/char* is undefined behaviour in C specification. Or this is a gcc extension? (use uintptr_t cast on a function pointer to get the start address of the function code). If it's true, where I could found the detailed specification? Thanks a lot :) Remus